gpt4 book ai didi

php - 为什么此代码适用于 PHP 版本 5.2.10 而不适用于 PHP 版本 5.2.10-2?

转载 作者:行者123 更新时间:2023-12-04 18:58:41 24 4
gpt4 key购买 nike

使用此代码,我正在遍历一个对象。为什么这可以在我的带有 PHP 5.2.10 的 WAMP 盒子上工作,而不是在我的 Ubuntu 9.10 安装中使用来自 repo 的 PHP 5.2.10-2?

$incomingData = json_decode($_POST['data']);

foreach($incomingData as $key => $action)
{

}

Invalid argument supplied for foreach()

最佳答案

wzzrd 是正确的。这应该在 stackoverflow 上,问题在于 json_decode 的返回值不是您所期望的。

来自 http://php.net/json_decode

Returns the value encoded in json in appropriate PHP type. Values true, false and null (case-insensitive) are returned as TRUE, FALSE and NULL respectively. NULL is returned if the json cannot be decoded or if the encoded data is deeper than the recursion limit.



您是否在两台服务器上发出相同的请求(&data=xxx 完全相同)?那将是首先要验证的事情。

假设是,您的 php.ini 是否相似?
magic_quotes_gpc=1将改变 $_GET/$_POST/$_COOKIE 并且可能是罪魁祸首。

关于php - 为什么此代码适用于 PHP 版本 5.2.10 而不适用于 PHP 版本 5.2.10-2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2008025/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com