时间:2021-07-01 10:21:17 帮助过:22人阅读

PHP is_numeric 检测变量是否为数字或数字字符串(推荐学习:PHP编程从入门到精通)
bool is_numeric ( mixed $var )
如果 var 是数字和数字字符串则返回 TRUE,否则返回 FALSE。
For example 1:
<?php
$v = is_numeric ('58635272821786587286382824657568871098287278276543219876543') ? true : false;
var_dump ($v);
?>
The above script will output:
bool(true)For example 2:
<?php
$str="0";
$strTest=is_numeric(0);
var_dump($strTest);
?>
boolean true
//
function int_str($str){
if(is_numeric($str)){
$str = 'm'.$str;
}
return $str;
}以上就是PHP判断是不是数字的详细内容,更多请关注Gxl网其它相关文章!