Consistent 64-bit Support

PHP 5 already featured full 64-bit support on Linux. For Windows, before PHP 7, only 32-bit versions were available and officially supported, let aside some experimental 64-bit builds of PHP 5.5 and PHP 5.6.

Now, PHP also supports native 64-bit integers on Windows. Allegedly, the main reason why 64-bit integers had been introduced into PHP were database keys. Databases, designed to store large amounts of data, like to use integers as primary keys. When those keys are 64 bits long, and PHP only supports 32-bit integers, there is a problem with handling large keys in PHP, because they are represented as floating point numbers, which leads to precision loss. When converting such keys back to integer, for example when writing a record back to the database, the key might suddenly point to another record.

On a 32-bit system, the largest positive integer is:

$ php -r 'echo PHP_INT_MAX;'
2147483647

On a 64-bit system, we get:

$ php -r 'echo PHP_INT_MAX;'
9223372036854775807

Please note that 32-bit builds of PHP 7 are still available. Make sure to pick a 64-bit build when installing PHP.

64-bit support, however, is not only about integer size. It also allows for handling of strings that are longer than 2^31 characters, support for numeric 64-bit hash keys, and support for large files. Large files reach or exceed 2 GB (2^31 bytes) or 4 GB (2^32 bytes) in size, depending on whom you ask. Seriously: the limit depends on whether signed or unsigned integers are used to represent the file size.

With PHP 7, integer and string length handling is consistent across the most commonly used 64-bit platforms LP64 (Linux/Unix), LLP64 (Windows), and ILP64 (Sparc). This is one of the reasons why support for many unused or rarely used so-called Server APIs have been dropped.

64-bit support also solves the year 2038 problem: on January 19th, 2038, 32-bit integers representing a Unix timestamp will overflow. 64-bit integers will give us a bit more time: they will not overflow before the sun starts to turn into a red giant, which will probably not leave us with a lot of working computers to worry about.