note 27326 added to function.is-numeric
| From: | martijnt at rack1 dot php dot net | Date: | Mon, 02 Dec 2002 11:21:13 +0000 |
| Subject: | note 27326 added to function.is-numeric | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-40240@lists.php.net to get a copy of this message | ||
If you want to make sure that a variable contains only one or more numbers as in the range 0-9, you
could use this:
eregi("[^0-9]",$var)
This checks your variable for anything that is NOT in the range 0-9.
If you use is_numeric() while checking an IP address, you should not be surprised if the following
is accepted as a valid IP: 1e13.3.4.12e3 -> is_numeric() considers 1e13 and 12e3 as valid numeric
values (which is correct).
Have fun.
Martijn Tigchelaar,
DataServe.
--
http://www.php.net/manual/en/function.is-numeric.php
http://master.php.net/manage/user-notes.php?action=edit+27326
http://master.php.net/manage/user-notes.php?action=delete+27326
http://master.php.net/manage/user-notes.php?action=reject+27326