PHP is_numeric 检测变量是不是为数字或数字字符串
函数语法:
bool is_numeric ( mixed $var )
假如 var 是数字和数字字符串则返回 TRUE,不然返回 FALSE。
实例1:
<?php $v = is_numeric ('58635272821786587286382824657568871098287278276543219876543') ? true : false; var_dump ($v); ?> The above script will output: bool(true)
实例2:
<?php $str="0"; $strTest=is_numeric(0); var_dump($strTest); ?> boolean true
学问扩大:
is_bool()
;//推断是不是为布尔型is_float()
; //推断是不是为浮点型is_int()
; //推断是不是为整型is_numeric()
; //推断是不是为数值型is_string()
; //推断是不是为字符串is_array()
; //推断是不是为数组is_object()
; //推断是不是为对象
引荐教程:PHP视频教程
以上就是php推断是不是是数字范例的细致内容,更多请关注ki4网别的相干文章!