To infinity and beyond! Working with infinity in PHP

Josh Sherman
1 min read
Software Development 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!

Join the Conversation

Good stuff? Want more?

Weekly emails about technology, development, and sometimes sauerkraut.

100% Fresh, Grade A Content, Never Spam.

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.

Currently Reading

Parasie Eve

Previous Reads

Buy Me a Coffee Become a Sponsor

Related Articles