Not quite. To understand the nature of NULL you must consider the following. Suppose you have a variable $foo you wish to 'destroy' you can do so by doing unset($foo) or $foo = NULL;. In both cases the value of $foo will be destroyed, however the variable will remain, it's value will become NULL.

Doing an unset($foo) and $foo=null are two completely different outcomes in PHP. As you know unset actually destroys the variable from the current scope, as well as
the value. It doesn't exist, nor is it set.
Doing a $foo=null, does not destroy the variable. It still exists, and is set.


unset($foo);

echo $foo; //<-- you get a nice php Notice, because this variable doesn't exist

versus

$foo=nul;

echo $foo; //no warnings at all because the variable does exist and it is set!

Therefor isset() behaviour, which works by seeing if a variable exists and making sure that its value is not null, is correct and now flawed as you claim. This is true for other languages as well such as C, when a pointer's value is null that pointer is 'no set'.

Ilia




In C, you can easily say a pointer set to 0x0/null, is in fact set. Are you always guarenteed that
char *foo; is going to be set to 0x0 ?


I would say it is more wise to do
char *foo = null; Now you know that the foo pointer is set! and has a value of null.


At the very least, one could say that isset() is confusing, and not what a lot of folks expect it to do. Yes, the documentation states the functionality, even if it is confusing.

Walt


-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to