2

我有以下代码:

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;

不是响应是Object of class stdClass could not be converted to string。请帮忙,我有一个截止日期(1 小时),但我无法正常工作。

4

3 回答 3

5

像数组一样,您不能回显 stdClass 对象。您可以var_dump($array_diff)像这样回显特定属性:

echo $array_diff->my_property;
于 2013-05-24T10:32:50.407 回答
1

之后$array_diff = json_decode($string_diff);$array_diff是一个对象,所以你不能只是回应它。尝试类似的东西

echo $array_diff->your_property;
于 2013-05-24T10:34:11.750 回答
0

用于print_r打印关于变量的人类可读信息:

print_r($array_diff);
于 2016-07-19T06:22:50.520 回答