php - 为什么 ctype_digit(0) 返回 FALSE

标签 php

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 0NULL ,所以它返回 false。

关于php - 为什么 ctype_digit(0) 返回 FALSE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8557973/

相关文章:

php - 位置 : add ID to URL after update

php - 如何拦截数据库请求? (MySQL)

javascript变量传递给 map 中的php

php - 如何修复PHP中的 “Headers already sent”错误

php - var_dump(0 == 'all');//为什么为真

php - 一种用于风景和肖像照片的 CSS 样式

php - 从源代码安装 php 时出错

PHP/MySQL : querying MySQL with an array and getting results in an array

javascript - 如何将 Facebook PHP 访问 token 与用于 FB.UI 对话框的 FB Javascript SDK 一起使用

php - 我需要做什么才能看到数据库元素(foreach 循环)