note 75529 deleted from function.ctype-digit by philip
| From: | philip@php.net | Date: | Sun, 22 Feb 2009 21:13:58 +0000 |
| Subject: | note 75529 deleted from function.ctype-digit by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-150966@lists.php.net to get a copy of this message | ||
Note Submitter: robert at mediamonks dot com
----
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.