Jimmy小站

小明也有大梦想 — 蒋明/铭
当前位置:网站首页 / 未分类 / 正文

PHP json_decode() 返回类型问题

2016-12-03 / 未分类 / 3857 次围观 / 0 次吐槽

It decode correctly,It show the result correctly when I debug code. but when I try to access the info inside the array,such as

when I tried to do: $data['isExtra'] = 0 and $data has been modified,

and I get the Error:

Fatal error: Cannot use object of type stdClass as array inC:\Users\Dail\software\abs.php on line 108

Now we can solve this issue by using the code as below:

$data= json_decode('sourceStr', true); Adding the second parameter as true to returns the result as an array and not an stdClass.


推荐您阅读更多有关于“PHP,”的文章

[一个Java程序猿的转型之路,读研深造,专注机器学习推荐算法]
本站所有文章如无特别注明均为原创。作者:吉米酱 ,复制或转载请以超链接形式注明转自 Jimmy小站
原文地址《PHP json_decode() 返回类型问题
额 本文暂时没人评论 来添加一个吧

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

Copyright © Jimmy小站 Allrights Reserved.备案号:桂ICP备 15005996