开发者

Why does this code work on PHP Version 5.2.10 and not on PHP Version 5.2.10-2?

With this code I am iterating trough an object. Why is this working on my WAMP box with PHP 5.2.10 and isn't it on my Ubuntu 9.10 installation with PHP 5.2.10-2 from the repo's?

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

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

}

Invalid argument开发者_如何学Go supplied for foreach()


wzzrd is correct. This should likely be on stackoverflow, and the issue will be with the return value from json_decode not being what you expected.

From 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.

Are you making the same request on both servers (&data=xxx is exactly the same)? That'd be the first thing to verify.

Assuming yes, are your php.ini's similar?

magic_quotes_gpc=1 will alter $_GET/$_POST/$_COOKIE and is the likely culprit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜