note 85784 rejected from function.ctype-digit by thiago
| From: | thiago@php.net | Date: | Wed, 17 Sep 2008 18:09:54 +0000 |
| Subject: | note 85784 rejected from function.ctype-digit by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-144487@lists.php.net to get a copy of this message | ||
Note Submitter: matt at doodoostyle dot com
----
An interesting result I get on one of my systems...
WinXP SP3, Apache 2.2.8, PHP 5.2.5 and 5.2.6 ( identical results )
<?php
error_reporting( E_ALL );
$digit = 12345;
var_dump( ctype_digit(12345) );
var_dump( ctype_digit($digit) );
var_dump( $digit );
?>
Returns
bool(true)
bool(true)
int(12345)
From what I gather, ctype_digit should return FALSE with an integral argument. This may be due to a
newer version of the function performing the typecasting internally? Regardless, for compatibility
purposes I still suggest typecasting any variables you feed into this function.
ctype_digit( (string)$digit );
Interesting this change isn't noted in the manual.