PHP is_finite() Function
The PHP is_finite() function is used to check if the argument is a finite value or not. It returns true (1) if the argument is finite, else returns false/nothing.
Syntax
is_finite(x)
Parameters
x |
Required. Specify the value. |
Return Value
Returns true (1) if the argument is finite, else returns false/nothing.
Example:
In the example below, is_finite() function is used to check if the argument is finite.
<?php echo var_dump(is_finite(10)); echo var_dump(is_finite(-10)); echo var_dump(is_finite(log(0))); echo "\n"; echo var_dump(is_finite(INF)); echo var_dump(is_finite(-INF)); echo var_dump(is_finite(NAN)); ?>
The output of the above code will be:
bool(true) bool(true) bool(false) bool(false) bool(false) bool(false)
❮ PHP Math Reference