#23158 [Com]: a new digit checker
| From: | michael at chunkycow dot com dot au | Date: | Mon, 31 Dec 2007 22:49:30 +0000 |
| Subject: | #23158 [Com]: a new digit checker | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-120963@lists.php.net to get a copy of this message | ||
ID: 23158
Comment by: michael at chunkycow dot com dot au
Reported By: melkor at dance dot student dot utwente dot nl
Status: Open
Bug Type: Feature/Change Request
Operating System: linux
PHP Version: 5CVS-2003-04-10 (dev)
New Comment:
This is bogus, ctype_digit(4500) returns true.
Previous Comments:
------------------------------------------------------------------------
[2003-04-10 17:31:15] melkor at dance dot student dot utwente dot nl
For ID's in databases, a simple is_digit($mixed) check would be nice.
is_numeric($mixed) also accepts 1.0E10 and such values, which are not
valid for integer database IDs.
ctype_digit($string) returns false for any integer it gets, because
ctype_digit(4500) gets translated to isdigit(4500) which of course is
not a valid ascii character at all.
This might seem a little far fetched, but lots and lots of code uses
is_numeric checks where they should not. I do this too, because
otherwise I need 2 checks (is_integer($var) || ctype_digit($var))..
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23158&edit=1