note 75529 added to function.ctype-digit
| From: | robertatmediamonksdotcom at osu1 dot php dot net | Date: | Mon, 04 Jun 2007 09:46:45 +0000 |
| Subject: | note 75529 added to function.ctype-digit | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-127179@lists.php.net to get a copy of this message | ||
I always used this function to check user input but it failed me when I wanted to check int's
used in my script. This is caused by the fact that the function only functions right when the
argument is a string. Here is a solution for this 'problem' :
<?php
$intCheckThis = 99;
$blnResult = ctype_digit($intCheckThis); // returns FALSE
$blnResult = ctype_digit(strval($intCheckThis)); // returns TRUE
?>
Note that user input from form or request uri is always handled as string anyway.
----
Server IP: 83.137.20.120
Probable Submitter: 82.204.32.210
----
Manual Page -- http://www.php.net/manual/en/function.ctype-digit.php
Edit -- https://master.php.net/note/edit/75529
Del: integrated -- https://master.php.net/note/delete/75529/integrated
Del: useless -- https://master.php.net/note/delete/75529/useless
Del: bad code -- https://master.php.net/note/delete/75529/bad+code
Del: spam -- https://master.php.net/note/delete/75529/spam
Del: non-english -- https://master.php.net/note/delete/75529/non-english
Del: in docs -- https://master.php.net/note/delete/75529/in+docs
Del: other reasons-- https://master.php.net/note/delete/75529
Reject -- https://master.php.net/note/reject/75529
Search -- https://master.php.net/manage/user-notes.php