note 29456 added to function.empty

From: Date: Fri, 14 Feb 2003 03:46:49 +0000
Subject: note 29456 added to function.empty
Groups: php.notes 
Request: Send a blank email to php-notes+get-43911@lists.php.net to get a copy of this message
<---- i havent quite figured out what system will work for testing "empty" variables .. i believe they are either !isset or they have something in them if isset=true.. -----> Look at this code : <?php ************** if (!isset($a)) { echo "the variable doesnt exist!"; } elseif (empty($a)) { echo "it exists but is empty!"; } else { echo "it exists and contains something!"; } ?> If you replace * with blank space, you get "the variable doesnt exist!" If you replace * with $a = 1; you get "it exists and contains something!" If you replace * with $a = array(); you get "it exists but is empty!" -- http://www.php.net/manual/en/function.empty.php http://master.php.net/manage/user-notes.php?action=edit+29456 http://master.php.net/manage/user-notes.php?action=delete+29456 http://master.php.net/manage/user-notes.php?action=reject+29456

« previous php.notes (#43911) next »