I am running PHP 7.0.8 (VC14 x64 Thread Safe version) on Windows 7.
echo PHP_INT_MAX;
shows 9223372036854775807
, but this doesn't actually seem to be correct. According to the PHP documentation,
If PHP encounters a number beyond the bounds of the integer type, it will be interpreted as a float instead.
but when I run the code from the documentation that demonstrates integer overflow on a 32-bit system, that's not what happens.
$large_number = 2147483647;
var_dump($large_number); // expected: int(2147483647) actual: int (2147483647)
$large_number = 2147483648;
var_dump($large_number); // expected: float(2147483648) actual: int (-2147483648)
Even more strangely, the other example from the docs:
$large_number = 9223372036854775807;
var_dump($large_number); // expected: int(9223372036854775807) actual: int(-1)
$large_number = 9223372036854775808;
var_dump($large_number);
// expected: float(9.2233720368548E+18), actual: float(9.2233720368548E+18)
Is this a bug, or am I misunderstanding something? The only similar bug I've found deals with incorrect output of var_dump(PHP_INT_MAX)
with xdebug (which is present in my version), but that doesn't seem to explain what's happening here. If anyone knows of relevant info I should include from phpinfo
I can add it.