note 16766 added to language.types.null

From: Date: Mon, 12 Nov 2001 20:52:06 +0000
Subject: note 16766 added to language.types.null
Groups: php.notes 
Request: Send a blank email to php-notes+get-20765@lists.php.net to get a copy of this message
Nulls are almost the same as unset variables and it is hard to tell the difference without creating errors from the interpreter: $var = NULL; isset($var) is FALSE empty($var) is TRUE is_null($var) is TRUE isset($novar) is FALSE empty($novar) is TRUE is_null($novar) gives an Undefined variable error $var IS in the symbol table (from get_defined_vars()) $var CAN be used as an argument or an expression. So, in most cases I found that we needed to use !isset($var) intead of is_null($var) and then set $var = NULL if the variable needs to be used later to guarantee that $var is a valid variable with a NULL value instead of being undefined. -- http://www.php.net/manual/en/language.types.null.php http://master.php.net/manage/user-notes.php?action=edit+16766 http://master.php.net/manage/user-notes.php?action=delete+16766 http://master.php.net/manage/user-notes.php?action=reject+16766

« previous php.notes (#20765) next »