NYCPHP Meetup

NYPHP.org

[nycphp-talk] ${$variable}

Chris Snyder csnyder at chxo.com
Wed Aug 27 16:40:30 EDT 2003


Okay folks, here's the scoop. Based on some extensive testing at
http://chxo.com/scripts/emptytest.php

To test for an empty string, you have to test that it is both empty AND 
a string.

if ( is_string($$foo) && empty($$foo) ) do empty string stuff here

Otherwise $$foo could be 0 or not set at all. I humbly take back any 
misinfo I spread earlier, Michael.

     chris.

Michael Southwell wrote:

> A line of code says this:
>   if (!(${$foo})) do something if the value is empty
>
> If $foo="bar" and $bar="something" then will ${$foo} evaluate to 
> "something"--which I assume is the purpose of the curly brackets?  But 
> it doesn't seem to work when the value is empty, though I would swear 
> it used to.  or maybe there is something with an empty value 
> evaluating true anyway, so I need to use =="" or ==="", or =='' or 
> ==='' (single quotation marks)?  Is this tricky, or am I just ignorant?
>
> Michael G. Southwell =================================
> DNEBA Enterprises
> 81 South Road
> Bloomingdale, NJ 07403-1419
> 973/492-7873 (voice and fax)
> southwell at dneba.com
> http://www.dneba.com
> ======================================================
>
>
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk





More information about the talk mailing list