intval:
echo intval('1000000000000');
returns 2147483647.
Why?
The size of an integer in PHP is platform-dependent. The documentation for intval()
clearly explains this:
The maximum value depends on the system. 32 bit systems have a maximum signed integer range of -2147483648 to 2147483647. So for example on such a system, intval('1000000000000') will return 2147483647. The maximum signed integer value for 64 bit systems is 9223372036854775807.
From the same documentation you shared..
The maximum value depends on the system. 32 bit systems have a maximum signed integer range of -2147483648 to 2147483647. So for example on such a system, intval('1000000000000') will return 2147483647. The maximum signed integer value for 64 bit systems is 9223372036854775807.
echo intval('1000000000000');
returns 2147483647. Why?
is because the system you're trying is 32 bits system
Because
1. You have 32 bit systems.
2. That's why you can operate a maximum signed integer range of -2147483648 to 2147483647`.
For this value there will be no problem if You had 64 bit systems Antother example:
On 32 bit systems
echo intval('420000000000000000000'); // 2147483647
On 64 bit systems
echo intval('420000000000000000000'); // 420000000000000000000