dsce23640 2019-04-12 13:36
浏览 75
已采纳

PHP 5.6返回结果,如PHP 5.2

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.

  • 写回答

1条回答 默认 最新

  • dongtan7639 2019-04-12 13:53
    关注

    Okay i figured out what is going on. We actually have jsonc extension which is drop-in replacement for native json support in php.

    This issue actually pointed me to good direction - https://github.com/remicollet/pecl-json-c/issues/13

    Indeed we just have outdated jsonc version and that's it.

    $ php --ri json
    
    json
    
    json support => enabled
    json version => 1.3.6
    JSON-C headers version => 0.11.99
    JSON-C library version => 0.11.99
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭