is_finite()
is_finite() — Checks whether a float is finite.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
Signature
is_finite(float $num): bool
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $num | float | The float to check |
Return value
true if num is none of NAN, INF, -INF, else false.
Example
A runnable snippet:
$float = 1.2345; var_dump($float, is_finite($float)); $nan = sqrt(-1); var_dump($nan, is_finite($nan)); $inf = 1e308 * 2; var_dump($inf, is_finite($inf));
Output:
float(1.2345) bool(true) float(NAN) bool(false) float(INF) bool(false)
See also
All PHP 8.5 built-in functions
Reference card built from the PHP manual page is_finite() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.