Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
finite
math
communitycreator

What is is_finite() in PHP?

Harris Amjad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The is_finite() function in PHP returns True (1) if the value is finite. Otherwise, it returns False(nothing). In other words, this function checks if the number is finite or not.

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

Figure 1: Visual representation of is_finite() function

Syntax


bool is_finite(number)

Parameter

This function requires the number as a parameter.

Return value

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

Code

The following example shows how to use is_finite() in PHP:

<?php
#number
echo("is_finite(10): ");
echo (is_finite(10));
echo("\n");
echo("is_finite(5.3): ");
echo (is_finite(5.3));
echo("\n");
echo("is_finite(-5.3): ");
echo (is_finite(-5.3));
echo("\n");
echo("is_finite(0): ");
echo (is_finite(0));
?>
<?php
#infinity
echo("is_finite(log(0)): ");
echo (is_finite(log(0)));
echo("\n");
echo("is_finite(INF): ");
echo (is_finite(INF));
echo("\n");
echo("is_finite(-INF): ");
echo (is_finite(-INF));
?>

RELATED TAGS

php
finite
math
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring