Example 1 — Detect infinity
Check positive infinity, negative infinity and a normal number.
<?php
echo var_export(is_infinite(INF), true) . PHP_EOL;
echo var_export(is_infinite(-INF), true) . PHP_EOL;
echo var_export(is_infinite(5.5), true) . PHP_EOL; How It Works
- INF is a built-in PHP constant for positive infinity.
- -INF is negative infinity, which also counts as infinite.
- 5.5 is a normal number, so the result is false.
- var_export(..., true) converts the boolean into printable text.

