note 72170 deleted from language.types.null by nlopess
| From: | nlopess@php.net | Date: | Fri, 05 Jan 2007 20:30:21 +0000 |
| Subject: | note 72170 deleted from language.types.null by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-121330@lists.php.net to get a copy of this message | ||
Note Submitter: Stephen
----
PHP's NULL value seems to be a bit of a fraud. As somebody has already noted, the following
will throw a "variable not defined" error:
print ((is_null($blah_blah)) ? 'true' : 'false');
What wasn't noted earlier is that this should not be happening. As per the definition above, a
variable is considered to be NULL if it is not defined. So by definition, is_null should not be
throwing "variable not defined" errors.
The same thing will happen with both equality and identity operators:
print (($blah_blah == NULL) ? 'true' : 'false');
print (($blah_blah === NULL) ? 'true' : 'false');
Both these throw the same error.
So in sum it seems that NULL doesn't *actually* mean NULL in PHP. It is simply a separate type
that means something different from the other types, but behaves in the same way as the other types.
I consider this to be a significant shortcoming in the PHP language. Hopefully PHP will adopt the
MySQL-style NULL value behavior in the future.