<?php
$str='18.8';
if(is_numeric($str)){
echo 'zheng';
}else{
echo 'jia';
}
if(is_string($str)){
echo 'zheng';
}else{
echo 'jia';
}
?>
天蓬老师2017-11-11 22:55:46
The parameter of the is_numeric() function is a number or a numeric string. Your parameter '18.8' is a numeric string and meets the conditions, so it returns "true";
What you want to test is '18.8', you should use: is_float() function to test. If you want to test integer, please use is_int()
More usage, Can parameter PHP User Manual