PHP Function Reference

PHP is_nan() Function



The PHP 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 example below, is_nan() function is used to check if the argument is "not a number" or not.

<?php
echo var_dump(is_nan(10));
echo var_dump(is_nan(log(-10)));
echo var_dump(is_nan(acos(5))); 

echo "\n"; 
echo var_dump(is_nan(INF));
echo var_dump(is_nan(-INF));
echo var_dump(is_nan(NAN));   
?>

The output of the above code will be:

bool(false)
bool(true)
bool(true)

bool(false)
bool(false)
bool(true)

❮ PHP Math Reference