我有以下代码:
if ($difference)
{
$.post("recover_functions/upload_photos.php",
{upload:$difference},
function(response)
{
alert($difference);
if (response.status)
alert("Successfully uploaded photos");
else
alert(response);
});
}
警报将显示:
{"difference":"[{\"aid\":\"100000543443572_1073741825\",\"backdated_time\":null,\"caption\":\"\",\"link\":\"http:\\\/\\\/www.facebook.com\\\/photo.php?fbid=614604095234366&set=a.614604001901042.1073741825.100000543443572&type=1\",\"pid\":\"100000543443572_2384218\",\"place_id\":null}]"}
然后我收到这样的 `POST 请求:
$string_diff = $_POST['upload'];
$array_diff = json_decode($string_diff);
echo $array_diff;
不是响应是类 stdClass 的对象无法转换为字符串
。
请帮忙,我有一个截止日期(1 小时),但我无法正常工作。
最佳答案
与数组一样,您不能回显 stdClass 对象。您可以像这样 var_dump($array_diff)
并回显特定属性:
echo $array_diff->my_property;
关于php - stdClass 类的对象无法转换为字符串 - 找不到解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16732919/