Chapter 5. Numbers
Another fundamental building block of data in PHP is numbers. It’s easy to find different types of numbers in the world around us. The page number in a book is often printed in the footer. Your smartwatch displays the current time and perhaps the number of steps you’ve taken today. Some numbers can be impossibly large, others impossibly small. Numbers can be whole, fractional, or irrational like π.
In PHP, numbers are represented natively in one of two formats: as integers (the
int type) or as floating-point numbers (the
float type). Both numeric types are highly flexible, but the range of values you can use depends on the processor architecture of your system—a 32-bit system has tighter bounds than a 64-bit system.
PHP defines several constants that help programs understand the available range of numbers in the system. Given that the capabilities of PHP will differ greatly based on how it was compiled (for 32 or 64 bits), it is wise to use the constants defined in Table 5-1 rather than trying to determine what these values will be in a program. It’s always safer to defer to the operating system and language defaults.
The largest integer value supported by PHP. On 32-bit systems, this will be
The smallest integer value supported by PHP. On 32-bit systems, this will be