note 10838 deleted from language.variables by irc-html
| From: | irc-html@php.net | Date: | Sat, 19 Jan 2002 18:47:06 +0000 |
| Subject: | note 10838 deleted from language.variables by irc-html | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-25175@lists.php.net to get a copy of this message | ||
[Editor's Note: Zero (0) and NULL are not the same. The equals comparison operator (==) does a
loose comparison. It considers empty, NULL, and zero values to be equivalent. Use the strict
comparison operator (===) to ensure that the values you are comparing are of the same type and
value.
For an example of this behavior, try:
echo '0 == NULL is ', (0 == NULL) ? 'true' : 'false';
echo '0 === NULL is ', (0 === NULL) ? 'true' : 'false';
--zak@php.net]
[Ed: see also the is_null section - jeroen@php.net]
It is worth noting that
0 == NULL in PHP. I wish this were not so... having a value of zero is not the same as having no
value assigned... SQL makes the distinction nicely.
I would also like to see a NULL value (as well as attempts to dereference undefined values) cast to
"NULL" when coerced to a string ... making SQL coding in PHP much simpler and without a
need to perform suturing between the handling of defined vs undefined identifiers.