a shot of dev knowledge

RELATED TAGS

What is is_infinite() in PHP?

The is_infinite() function in PHP returns True (1) if the value is infinite. Otherwise, it returns False (nothing). In other words, this function is used to check if the number is infinite or not.

Figure 1 shows the visual representation of the is_infinite() function.

Figure 1: Visual representation of the is_infinite() function

Syntax

bool is_infinite(number)

Parameter

This function requires the number as a parameter.

Return value

This function returns True (1) if the value is infinite. Otherwise, it returns False (nothing).

Example

The following example shows how to use is_infinite() in PHP.

<?php
#number 
echo("is_infinite(10): ");
echo (is_infinite(10));
echo("\n");
echo("is_infinite(5.3): ");
echo (is_infinite(5.3));
echo("\n");
echo("is_infinite(-5.3): ");
echo (is_infinite(-5.3));
echo("\n");
echo("is_infinite(0): ");
echo (is_infinite(0));
?>	

<?php
#infinity
echo("is_infinite(log(0)): ");
echo (is_infinite(log(0)));
echo("\n");
echo("is_infinite(INF): ");
echo (is_infinite(INF));
echo("\n");
echo("is_infinite(-INF): ");
echo (is_infinite(-INF));
?>

RELATED TAGS

RELATED COURSES

View all Courses

Keep Exploring