is_nan() : whether a value is not a number

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 )
ParameterDESCRIPTION
$inputRequired : Number to check.
The output is TRUE if $input is 'not a number', else False.

We can check a input or variable is a number or not by using is_nan function. Note that we can't check a string with this function.
We can check square root of a negative number with is_nan() function. Here is a sample code 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)

Questions


Math Functions base_convert(): Convert number From any base to other decbin() Binary equivalent of decimal number dechex(): Convert decimal number to hexadecimal system
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    Post your comments , suggestion , error , requirements etc here





    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer