0

intval:

Get the integer value of a variable

echo intval('1000000000000');

returns 2147483647.

Why?

Robert Rocha
  • 9,510
  • 18
  • 69
  • 121

3 Answers3

2

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.

Amal Murali
  • 73,160
  • 18
  • 123
  • 143
1

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

zzlalani
  • 21,360
  • 16
  • 42
  • 72
0

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
sergio
  • 5,190
  • 7
  • 23
  • 45