Search code examples
php64-bitinteger

How can I have a 64-bit integer in PHP?


How can I have a 64-bit integer in PHP?

It seems like it is not by a config file, but rather it might be a compile-time option, and it depends on the platform.


Solution

  • Native 64-bit integers require 64-bit hardware AND the 64-bit version of PHP.

    On 32-bit hardware:

    $ php -r 'echo PHP_INT_MAX;'
    2147483647
    

    On 64-bit hardware:

    $ php -r 'echo PHP_INT_MAX;'
    9223372036854775807