PHP is_finite() 函数
is_finite() 是 PHP 的数学函数,用于判断一个值是否为合法的有限数。
语法
Bool is_finite ( float $val );
如果值是有限数,则返回 true (1),否则返回 false/无。
Parameter | Description | Required/Optional |
---|---|---|
value | Value to check | Required |
示例1
<?php
nos=2;
echo "Your given value is :".nos;
echo "<br>"."By using 'is_finite()' Function :".is_finite($nos);
?>
输出:
Your given value is :2
By using 'is_finite()' Function :1
示例2
<?php
echo "Your Number is: 20000";
echo "<br>"."By using 'is_finite()' function your value is:".is_finite(2000);
?>
输出:
Your Number is: 20000
By using 'is_finite()' function your value is:1
示例3
<?php
finite = 42;
var_dump(is_finite(infinite));
?>
输出:
bool(true)
示例4
<?php
infinite = log(0);
var_dump(is_finite(infinite));
?>
输出:
bool(false)
示例5
<?php
nan = acos(2);
var_dump(is_finite(nan));
?>
输出:
bool(false)