note 112040 added to function.ctype-digit
| From: | rlerne at gmail dot com | Date: | Thu, 25 Apr 2013 18:04:20 +0000 |
| Subject: | note 112040 added to function.ctype-digit | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-194624@lists.php.net to get a copy of this message | ||
Interesting to note that you must pass a STRING to this function, other values won't be
typecasted (I figured it would even though above explicitly says string $text).
I.E.
<?PHP
$val = 42; //Answer to life
$x = ctype_digit($val);
?>
Will return false, even though, when typecasted to string, it would be true.
<?PHP
$val = '42';
$x = ctype_digit($val);
?>
Returns True.
Could do this too:
<?PHP
$val = 42;
$x = ctype_digit((string) $val);
?>
Which will also return true, as it should.
----
Server IP: 64.71.164.2
Probable Submitter: 208.95.30.82
----
Manual Page -- http://php.net/manual/en/function.ctype-digit.php
Edit -- https://master.php.net/note/edit/112040
Del: integrated -- https://master.php.net/note/delete/112040/integrated
Del: useless -- https://master.php.net/note/delete/112040/useless
Del: bad code -- https://master.php.net/note/delete/112040/bad+code
Del: spam -- https://master.php.net/note/delete/112040/spam
Del: non-english -- https://master.php.net/note/delete/112040/non-english
Del: in docs -- https://master.php.net/note/delete/112040/in+docs
Del: other reasons-- https://master.php.net/note/delete/112040
Reject -- https://master.php.net/note/reject/112040
Search -- https://master.php.net/manage/user-notes.php