note 44206 modified in function.empty by tomsommer
| From: | tomsommer@php.net | Date: | Thu, 05 Aug 2004 21:23:53 +0000 |
| Subject: | note 44206 modified in function.empty by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-74091@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 returns true on zero(0) values.
--was--
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";
}
http://php.net/manual/en/function.empty.php