On Wednesday, February 6, 2002, at 03:28  PM, CC Zona wrote:

> PHP's loose typing means that !$somevar evalutes as true if the 
> variable is
> null, if it has an (integer, float, or string) value of zero, if it's an
> empty string, or if it is set to boolean false. Or if the variable/index
> does not exist.
>
> Both methods have their place (though for tests of the latter, I prefer
> empty()).  The important part is understanding the implications of a 
> method
> when you use it, so that your code isn't wrongly relying on !$somevar to
> mean the variable isn't set; it may well have been set, to a meaningful
> value which just happens to evaluate to false.
>


I guess the best thing to do is to test it each way when I'm testing for 
variables and make sure that the method I end up going with works 
correctly for "true" and "false" values, whatever they may end up 
being.  No BFD, I was just wondering if there was a definite method for 
doing these tests.

Thanks to all who've responded on this thread.


Erik



----

Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to