Re: wrong implementation of isset()?
| From: | Mark J. Hershenson | Date: | Tue, 06 Feb 2001 20:08:21 +0000 |
| Subject: | Re: wrong implementation of isset()? | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-45869@lists.php.net to get a copy of this message | ||
>> Great analysis. What about answering the question? Stanislav Malyshev
>> said some months ago this is 'strange', see the discussion around bug
>> 6076. Tell us at least, why this actually isn't strange.
>
> By default, any unset variable has value NULL - and isset(NULL) returns
> false to indicate that. Similarly, assigning NULL to a variable unsets
> it.
>
> -Andrei
> * The great thing about standards is that there are so many to choose from. *
Well, sure, isset(NULL) should return false, it's not a variable set in the
scope. A constant(?) yes, but not a variable.
But if you set a variable at some point in a script, would it not stand to
reason that that name is in the global/local namespace, and therefore IS
set?
It's somewhat conflicting when you reason:
<?php
$a = 1;
$b = 2;
$c = NULL;
print_r($GLOBALS);
?>
Yields:
<snip>
[GLOBALS] => Array
*RECURSION*
[a] => 1
[b] => 2
[c] =>
)
So, $c is set, since it is contained in $GLOBALS. Yet it's not, because it's
NULL.
I vote for isset() on a NULL value should be true if it's in the namespace.
Mark J. Hershenson
markhers@green-ant.com
http://www.green-ant.com/