On Thu, 18 Apr 2002, Norman Zhang wrote: > I am looking at some codes. Some authors use $foo and isset($foo) > interchangeably. Just to want to make sure that the statement, > > if ($foo) { ... } > > is different from > > if (isset($foo)) { ... } > > Right? if ($foo) means variable exists and can be null. Whereas, isset($foo) > means that the value in $foo cannot be null?
Not quite (or maybe I just don't understand your sentence). if ($foo) will be true if $foo has been set to some non-null (and non-zero) value. It will be false if $foo==null. On the other hand, if (isset($foo)) will be true will be true if any value at all has been assigned to $foo, including null or zero. It will only be false if $foo has never been assigned in this scope. However, bear in mind that ($foo) will still evaluate to null even in this case. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php