2
ctype_digit(0)
回报FALSE
为什么ctype_digit(0)返回FALSE
ctype_digit("0")
回报TRUE
按照PHP的类型转换0应该被提升到字符串 “0”。但是当调用0或1或2时,它不会被提升为一个字符串。为什么?
ctype_digit(0)
回报FALSE
为什么ctype_digit(0)返回FALSE
ctype_digit("0")
回报TRUE
按照PHP的类型转换0应该被提升到字符串 “0”。但是当调用0或1或2时,它不会被提升为一个字符串。为什么?
$numeric_string = '42';
$integer = 42;
ctype_digit($numeric_string); // true
ctype_digit($integer); // false (ASCII 42 is the * character)
ASCII 0
是NULL
,所以返回false。
相似主题:http://stackoverflow.com/questions/5962529/ctype-digit-strange-behaviour。我很想知道为什么PHP允许这种类型转换异常。为什么php手册没有为ctype_digit列出这种特殊性! – AgA 2011-12-19 06:46:14
对不起:http://php.net/manual/en/function.ctype-digit.php原因列在底部,这是不是在我的PHP CHM手册。 – AgA 2011-12-19 06:48:47