SQL PHP HTML ASP JavaScript articles and free scripts to download
PHP Math

PHP Math functions is_nan

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";
}

Out put is

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

Be the first to post comment on this article :


Google+

Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer