In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Erik Price) wrote:

> Pretty confusing.  Can anyone shed some light on whether or not there is 
> a final definite way to do this?  I've used (!($_POST['var'])) with no 
> problems in the past, but does good coding style suggest that I use 
> (!isset($_POST['var'])) now?

"!$somevar" != "!isset($somevar)"

isset() evaluates as true only if the variable (or array index) exists.

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.

-- 
CC

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

Reply via email to