Re: problem with intval and !=
| From: | John W. Holmes | Date: | Thu, 23 Oct 2003 16:41:56 +0000 |
| Subject: | Re: problem with intval and != | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-167313@lists.php.net to get a copy of this message | ||
Greg Beaver wrote:
http://www.php.net/is_numeric is the function you are looking for. No need for fancy regexps.The OP is looking for an integer, but is_numeric() will return true for float values and also for numbers in scientific notation. So "12.3" and "12E3" will be TRUE. The original $number != intval($number) should work for detecting bad input. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com