To infinity and beyond! Working with infinity in PHP

We can file this one under the “PHP functions I never knew existed and probably
will never use” category. Seems that as of PHP 4.2.0 and beyond there was the
inclusion of an is_finite() and an is_infinite() function. The names are
pretty self explanatory and I’m sure there are some smart kids out there that
would use these (although I’d expect them to be working in a different language
😉

The usage is pretty simple, pass the function a value and it will return either
boolean true or false:

$value = log(0 // This is infinite

var_dump(
    is_infinite($value),
    is_finite($value

Comment below if you’ve used this function before in the real world, dying to
hear about it!

Josh Sherman - The Man, The Myth, The Avatar

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.


If you found this article helpful, please consider buying me a coffee.