is_numeric: Check whether it is a numeric string, it can be negative numbers and decimals
ctype_digit: Check whether the characters in the string are all numbers, negative numbers and decimals will fail the test
Note, the parameters must be certain If it is a string, if it is not a string, 0/FASLE will be returned
The following is a test example:
Copy code Code As follows:
$a = 0001111222;
var_dump($a);
var_dump(is_numeric($a)); //true
var_dump(ctype_digit($a) ); //true
$a = 0.1 ;
var_dump($a);
var_dump(is_numeric($a)); //true
var_dump(ctype_digit($a)); / /false
$a = -1 ;
var_dump($a);
var_dump(is_numeric($a)); //true
var_dump(ctype_digit($a)); //false
$a = a ;
var_dump($a);
var_dump(is_numeric($a)); //false
var_dump(ctype_digit($a)); //false
http://www.bkjia.com/PHPjc/326088.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326088.htmlTechArticleis_numeric: Check whether it is a numeric string, which can be negative numbers and decimals ctype_digit: Check whether the characters in the string are all It is a number. Negative numbers and decimals will fail the detection. Note that the parameters must be...