Request for Comments: 64-bit Integer type

This RFC is about adding a 64bit integer type to PHP.


Currently PHP's int type is 32bit on x86 systems, and 64bit on x64 systems. Sometimes you will need to handle numbers thats bigger than the 32bit integer limit and have to either use dirty hacks like converting to a float/string or use extensions like BCMath for such operations.

This RFC proposes a new type (“int64”), which always is 64bit long no matter the host arch.

User land


To remain consistent and not changing the current integer type declarings, a new prefix will be available for declaring 64bit long integers:

$int64 = L199938937393792738748327842;
var_dump($int64, L209938836626262738748327842);

Type casts

Like the integer type, you may also cast to a 64bit integer:

$int64str = '199938937393792738748327842';
var_dump((int64) $int64str);

The type cast have a “long” name alias too: (integer64)


New function(s) should be inserted into the core

  • is_int64 (Or maybe the is_int function should me modified)


Data type

The 64bit integer will internally be stored as 'zend_long64', as currently defined in zend_types.h


The API will be identical to the current type handling functions/macros that already exists:

  • IS_LONG64
  • convert_to_long64()
  • etc.

Parameter parsing

To parse the 64bit integer via the parameter_parsing API, the 'i' modifier will be in place like the 'l' for 'long'. Aswell as the 'I' modifier for limiting out of range values to minimum/maxmimum values of a zend_long64


Currently no patch is available, but it is in the works.

rfc/64bit-integer-type.txt · Last modified: 2017/09/22 13:28 (external edit)