PHP is_nan() 函数
PHP is_nan() 函数用于检查一个值是否为非数字。这是一个重要的数学函数。
如果该值不是数字,函数返回true。否则返回false/无。
语法
bool is_nan ( float $val );
Parameter | Description | Required/Optional |
---|---|---|
Value | Value to check | Required |
示例1
<?php
nos =200;
echo "Your value is :".nos;
echo "<br>"."By using 'is_nan()' Function your value is:".is_nan($nos);
?>
输出:
Your value is :200
By using 'is_nan()' Function your value is:
示例2
<?php
nos =acos(1.01);
echo "Your value is :acos(1.01)";
echo "<br>"."By using 'is_nan()' Function your value is:".is_nan(nos);
?>
输出:
Your value is :acos(1.01)
By using 'is_nan()' Function your value is:1
示例3
<?php
finite =40;
var_dump(is_nan(finite));
?>
输出:
bool(false)
示例4
<?php
infinite = log(0);
var_dump(is_nan(infinite));
?>
输出:
bool(false)
示例5
<?php
nan = acos(2);
var_dump(is_nan(nan));
?>
输出:
bool(true)