64-bit PHP overcomes the stupid signed-integer limit
https://marco.org/2008/06/03/64-bit-php-overcomes-the-stupid-signed-integer-limit
PHP’s integer type has always been a 32-bit signed integer with a maximum value of 2,147,483,647. I thought there was no alternative.
Today I learned that you get 64-bit integers if you use the 64-bit version of PHP, so the maximum value is MUCH higher (9.2×1018).
If you don’t know, here’s how to tell:
32-bit:
$ echo '<?= PHP_INT_MAX . "\n" ?>' | php
2147483647
$ echo '<?= intval(9223372036854775807) . "\n" ?>' | php
-1
64-bit:
$ echo '<?= PHP_INT_MAX . "\n" ?>' | php
9223372036854775807
$ echo '<?= intval(9223372036854775807) . "\n" ?>' | php
9223372036854775807
This comes in handy if you use AUTO_INCREMENT integer IDs on tables with more than 2.1 billion entries…