PHP is_infinite() 函数
is_infinite() 是一个重要的 PHP 数学函数,用于检查一个值是否为无穷大。
当值为无穷大时,返回 true;否则返回 false / 无。
语法
bool is_infinite ( float $val );
Parameter | Description | Required/Optional |
---|---|---|
Value | The value to check | Required |
示例1
<?php
infinite = log(0);
var_dump(is_finite(infinite));
?>
输出:
bool(false)
示例2
<?php
infinite = 42;
var_dump(is_finite(infinite));
?>
输出:
bool(true)
示例3
<?php
nan = acos(2);
var_dump(is_infinite(nan));
?>
输出:
bool(false)
示例4
<?php
nos =2;
echo "Your value is :".nos;
echo "<br>"."By using 'is_infinite()' Function your value is:".is_infinite($nos);
?>
输出:
Your value is 2
By using 'is_infinite()' Function your value is:
示例5
<?php
nos =2000;
echo "Your value is ".nos;
echo "<br>"."By using 'is_infinite()' Function your value is:".is_infinite($nos);
?>
输出:
Your value is 2000
By using 'is_infinite()' Function your value is:
注意:当输入是无限大的时候返回true,否则返回false/没有值。
示例6
<?php
nos =log(0);
echo "Your value is : log(0)";
echo "<br>"."By using 'is_infinite()' Function your value is:".is_infinite(nos);
?>
输出:
Your value is : log(0)
By using 'is_infinite()' Function your value is:1