I used the is_nan() function (i.e. is-not-a-number) to check if a variable taken from the query string is a number or not. However, if the variable is a string (in this case is_nan() should return TRUE ), the function also generates the following rather annoying warning:
Warning: is_nan() expects parameter 1 to be double, string given
Since is_nan() designed to check if a variable is not a number, why did it throw an error for the string? I would think that it should accept non-numeric parameters, since this is kind of a goal ...
Is there a reason why such a warning would be thrown? Does it make sense that I do not see here?
Note. If an error occurs, the function still behaves as expected - it returns TRUE for strings and FALSE for numbers. However, I wonder why it also issued a warning in case of a string.
Since then, I started using is_int() because I found that it is better suited for my purposes, and therefore I am not looking for an alternative. I'm just curious about this behavior.
source share