In PHP, the two functions is_numeric and ctype_digit both check whether the string is a number, but there is also a difference: is_numeric: checks whether it is a numeric string, can be a negative number and a decimal number
Ctype_digit: checks whether all characters in a string are numbers. negative and decimal digits cannot be detected.
Note that the parameter must be a string. if it is not a string, 0/FASLE is returned.
The following is a test example:
The code is as follows:
$ A = 0001111222;
Var_dump ($ );
Var_dump (is_numeric ($ a); // true
Var_dump (ctype_digit ($ a); // true
$ A = 0.1;
Var_dump ($ );
Var_dump (is_numeric ($ a); // true
Var_dump (ctype_digit ($ a); // false
$ A =-1;
Var_dump ($ );
Var_dump (is_numeric ($ a); // true
Var_dump (ctype_digit ($ a); // false
$ A =;
Var_dump ($ );
Var_dump (is_numeric ($ a); // false
Var_dump (ctype_digit ($ a); // false