note 44206 added to function.empty

From: Date: Sun, 18 Jul 2004 05:15:47 +0000
Subject: note 44206 added to function.empty
Groups: php.notes 
Request: Send a blank email to php-notes+get-73467@lists.php.net to get a copy of this message
Those of you, who are relying on empty() to detect/filter null/empty values, realize that empty() also filters zero(0) values. This is what i mean: $var=''; if(empty($var)) { echo "perfect and desired"; } whereas .. $var=0; or $var='0'; if(empty($var)) { echo "undesired but still true"; } so for such cases i advise you, to use this: if(empty($var) && $var!=0) { echo "will not be printed if var is zero"; } ---- Manual Page -- http://www.php.net/manual/en/function.empty.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44206 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44206&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44206&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#73467) next »