distinguish between null variable and unset variable
| From: | Jack Bates | Date: | Thu, 22 Jan 2009 01:27:35 +0000 |
| Subject: | distinguish between null variable and unset variable | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-286983@lists.php.net to get a copy of this message | ||
How can I tell the difference between a variable whose value is null and
a variable which is not set?
// cannot use === null:
ket% php -r '$null = null; var_dump(null === $null);'
bool(true)
ket% php -r 'var_dump(null === $unset);'
bool(true)
ket%
// - cannot use isset() either:
ket% php -r '$null = null; var_dump(isset($null));'
bool(false)
ket% php -r 'var_dump(isset($unset));'
bool(false)
ket%