note 36901 added to function.is-numeric
| From: | ste at REMOVEgolden dot net | Date: | Sun, 26 Oct 2003 17:23:20 +0000 |
| Subject: | note 36901 added to function.is-numeric | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-59336@lists.php.net to get a copy of this message | ||
It's important to test for is_numeric() before empty() - if the variable is 0 is will be
considered empty and never make it to the is_numeric test.
i.e.
$x=0;
if (empty($x))
print "$x is empty";
else if (is_numeric($x))
print "$x is numeric";
You will never see "0 is numeric", only "0 is empty".
This note is on the empty() page but I thought it should be noted here.
----
Manual Page -- http://www.php.net/manual/en/function.is-numeric.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36901
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36901&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36901&report=yes
Search -- http://master.php.net/manage/user-notes.php