note 83562 deleted from language.types.null by danbrown
| From: | danbrown@php.net | Date: | Tue, 19 May 2009 14:18:05 +0000 |
| Subject: | note 83562 deleted from language.types.null by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155732@lists.php.net to get a copy of this message | ||
Note Submitter: php_manual at SPAMNONE dot jessemccarthy dot net
----
The post by <rburghol a t veetee dot edu> has nothing to do with the special NULL value.
He's comparing a float (0.0) to a string ('NULL'). The special NULL value is
correctly represented as a bareword (NULL), not a string ('NULL').
<?php
/* start <rburghol a t veetee dot edu> example, with comment */
$tvar = 0.0;
// The string 'NULL' is converted to integer 0 for the comparison
if ($tvar == 'NULL') {
print("Match");
} else {
print("No Match");
}
/* end <rburghol a t veetee dot edu> example */
// Example using actual NULL
if ($tvar == NULL) {
print("Match");
} else {
print("No Match");
}
?>
Output:
Match
Match
It's the same result, but it's important to know what's happening and why, and how to
represent NULL.