Use single quotes for strings and integers, this is true for both
益波
益波 2017-11-04 18:23:26
0
1
1301

<?php

$str='18.8';

if(is_numeric($str)){

echo 'zheng';

}else{

echo 'jia';

}


if(is_string($str)){

echo 'zheng';

}else{

echo 'jia';

}

?>


益波
益波

reply all(1)
Peter_Zhu
  • 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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template