note 72170 added to language.types.null
| From: | Stephen at osu1 dot php dot net | Date: | Fri, 05 Jan 2007 15:37:31 +0000 |
| Subject: | note 72170 added to language.types.null | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-121321@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 66.163.161.117
Probable Submitter: 68.163.130.212
----
Manual Page -- http://www.php.net/manual/en/language.types.null.php
Edit -- https://master.php.net/note/edit/72170
Del: integrated -- https://master.php.net/note/delete/72170/integrated
Del: useless -- https://master.php.net/note/delete/72170/useless
Del: bad code -- https://master.php.net/note/delete/72170/bad+code
Del: spam -- https://master.php.net/note/delete/72170/spam
Del: non-english -- https://master.php.net/note/delete/72170/non-english
Del: in docs -- https://master.php.net/note/delete/72170/in+docs
Del: other reasons-- https://master.php.net/note/delete/72170
Reject -- https://master.php.net/note/reject/72170
Search -- https://master.php.net/manage/user-notes.php