note 118121 added to function.ctype-digit
| From: | smicheal2 at gmail dot com | Date: | Wed, 07 Oct 2015 13:21:04 +0000 |
| Subject: | note 118121 added to function.ctype-digit | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203924@lists.php.net to get a copy of this message | ||
Please note that ctype_digit() will say true for strings such as '00001', which are not
technically valid representations of integers, while saying false to strings such as '-1',
which are. It's basically a faster version of the regex /^\d+$/. As the name says, it answers
the question "does this string contain only digits" literally. It does not answer "is
this a valid representation of an integer". If that's what you want, use
is_int(filter_var($val, FILTER_VALIDATE_INT)) instead.
----
Server IP: 213.172.110.13
Probable Submitter: 217.160.127.250
----
Manual Page -- http://php.net/manual/en/function.ctype-digit.php
Edit -- https://master.php.net/note/edit/118121
Del: integrated -- https://master.php.net/note/delete/118121/integrated
Del: useless -- https://master.php.net/note/delete/118121/useless
Del: bad code -- https://master.php.net/note/delete/118121/bad+code
Del: spam -- https://master.php.net/note/delete/118121/spam
Del: non-english -- https://master.php.net/note/delete/118121/non-english
Del: in docs -- https://master.php.net/note/delete/118121/in+docs
Del: other reasons-- https://master.php.net/note/delete/118121
Reject -- https://master.php.net/note/reject/118121
Search -- https://master.php.net/manage/user-notes.php