php8.5
Home/ Manual/ math / functions/ is_infinite

is_infinite

PHP function Edit on GitHub ✎

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

Checks whether a float is infinite

Description

is_infinite(float $num): bool

Returns whether the given num is either INF or -INF.

Parameters

num

The Float to check

Return Values

true if num is either INF or -INF, else false.

Examples

is_infinite() example

php
<?php
$inf = 1e308 * 2;

var_dump($inf, is_infinite($inf));

$negative_inf = -$inf;

var_dump($negative_inf, is_infinite($negative_inf));
?>

The above example will output:

output
float(INF)
bool(true)
float(-INF)
bool(true)

See Also

Source: reference/math/functions/is-infinite.xml · from the official PHP manual (php/doc-en)