We recently occured weird error like:
json_decode(): integer overflow detected in Command line code on line 1
On our server with PHP 5.6.30(unforunately i don't know how it was built).
We had code like json_decode('{"key":999999999999999999999999999999999999999999999999999}', true)
What actually happened that we indeed had too big integer value. But what was interesting i run this code on 3v4l and in case of too big integer it should be converted to float - https://3v4l.org/IdJpZ
But what is more interesting that on php 5.2.0-5.2.3 it actually converts this number to max integer value instead, like:
array(1) {
["key"]=>
int(9223372036854775807)
}
So this is exactly output from this code and php -v
:
$ php -r "var_dump(json_decode('{\"key\":999999999999999999999999999999999999999999999999999}', true));"
PHP Notice: json_decode(): integer overflow detected in Command line code on line 1
array(1) {
["key"]=>
int(9223372036854775807)
}
$ php -v
PHP 5.6.30-0+deb8u1 (cli) (built: Feb 8 2017 08:50:21)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
Do you have any idea why our PHP 5.6.30 did the same behavior as PHP 5.2.0-5.2.3?
Also we use extension which actually requries at least PHP 5.4 and it works fine. Also we are using things like []
and it works fine too.