NAN
is a special constant. It must have some value, so it contains a float
data float
var_dump(NAN); // float(NAN);
The problem is that filter_var
not comparing data types, it is looking for numbers that are not NAN
.
Some numerical operations may result in a value represented by a NAN constant. This result represents an undefined or nonrepresentable value in floating point calculations. Any free or strict comparison of this value with any other value, including it, will have a FALSE result.
Because NAN represents any number of different values, NAN should not be compared with other values, including itself, and use is_nan () should be checked instead.
source share