echo is_nan(4); // Return False
echo "<br>";
echo is_nan(4.78); // Return False
echo "<br>";
echo is_nan(0); // Return False
echo "<br>";
echo is_nan(acos(2)); // Output is True
Syntax
bool is_nan ( float $input )
Parameter | DESCRIPTION |
---|---|
$input | Required : Number to check. |
$v = acos(1.1);
if(is_nan($v)){
echo "this is not a number";
}else{
echo "this is a number";
}
Output is here. More about acos()
this is not a number
You can change the line $v=acos(1.1) with different values of variable $v and see the result.
$v=5.23; // this is a number
$v=4; // this is a number
Getting the output by using var_dump()
echo var_dump(is_nan(4)); // bool(false)
echo "<br>";
echo var_dump(is_nan(4.78)); // bool(false)
echo "<br>";
echo var_dump(is_nan(0)); // bool(false)
echo "<br>";
echo var_dump(is_nan(acos(2))); // bool(true)
is_nan()
function in PHP do?is_nan()
function in PHP?is_nan()
function?is_nan()
function to check if a variable contains a NaN (Not a Number) value?true
when passed to the is_nan()
function?is_nan()
function differ from the isNaN()
function in JavaScript?is_nan()
function to check if a string is a valid number?is_nan()
function?is_nan()
function limited to specific data types, or can it work with different types of variables?Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.