PHP - Math is_nan() Function
The PHP Math is_nan() function is used to check if the argument is "not a number" or not. It returns true (1) if the argument is "not a number", else returns false/nothing.
Syntax
is_nan(x)
Parameters
x |
Required. Specify the value. |
Return Value
Returns true (1) if the argument is "not a number", else returns false/nothing.
Example:
In the below example, is_nan() function is used to check if the argument is "not a number" or not.
<?php echo var_dump(is_nan(2)); echo var_dump(is_nan(log(-1))); echo var_dump(is_nan(acos(5))); ?>
The output of the above code will be:
bool(false) bool(true) bool(true)
❮ PHP Math Functions