To see this problem, it should be very simple at first, and there are more ways than one.
Online check, most of the people are using Is_numeric method, but also often follow a sentence, do not think too complex, balabala ...
I did the next test, which is not necessarily correct, is_numeric in the manual is: the detection variable is a numeric or numeric string, a numeric string.
$a = "000022153.26"; Echo is_numeric ($a)? "Y": "N";
The results show Y
Obviously this is not the answer I want, according to some people on the internet, I think of another method, since Is_numeric is a numeric or numeric string, then the string is excluded from the line.
if (! is_string ($a)) { if (is_numeric ($a)) { echo "Y"; Exit ();} } echo "N";
Get the result is correct, N then see a person hint, use Is_nan, I tried the next, the last screen printing N, I began to quite excited, thought to, directly sent the article, in fact, it is wrong, it still put a $ A when float to parse, Is_nan In the manual meaning is to determine whether a number is a non-numeric value, is Nan, not a numbers, when $ A is a string type, such as "a", will be directly error, so using Is_nan is not able to determine whether a variable is a string
echo Is_nan ($a)? "Y": "N"
And after reading the handbook, we found the easiest way to find it.
$a = "0002133.226", if (Is_int ($a) | | is_float ($a)) { echo "Y"; } else{echo "N";}
The corresponding GetType ($a) is then compared with "integer" and "Double", if the match is the number, but this efficiency is not high, because it is a string comparison, it is relatively slow
I'm very sorry for those who read the article before, if they are misleading.
No Kuibu, not even thousands of miles.