Detecting if a null variable exists?
| From: | Brian Moon | Date: | Fri, 11 Jun 2010 17:43:07 +0000 |
| Subject: | Detecting if a null variable exists? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-48743@lists.php.net to get a copy of this message | ||
Is it just me or are we missing a way in the language to check if a variable that has been set to NULL exists or not?
is_null() on an unset variable throws a NOTICE.
$var === null throws a notice.
So, you have to use isset()? But, ah,
$var = null;
if(isset($var))
yields false.
Is array_key_exists("var", $GLOBALS) the only solution to this problem? Seems silly.
perhaps an var_exists() function is needed to fill this hole?
--
Brian.
--------
http://brian.moonspot.net/