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

nonopolarity picture nonopolarity · May 14, 2009 · Viewed 70.8k times · Source

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.

Answer

scotts picture scotts · May 14, 2009

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