【发布时间】:2021-12-07 18:31:49
【问题描述】:
我试图从这个 JSON 访问 ID 和 SENT,但对我不起作用。
更新
$json = '{
"response": {
"sent": true,
"message": "Sent to 57304",
"id": "gBEGVzBChXFYAgmcOrfFpGem8qw"
}
}';
json_decode($json);
$id=$json->id;
$sent=$json->sent;
echo "</br> id:".$id."</br>";
echo "</br> sent:".$sent."</br>";
【问题讨论】:
-
你需要将json字符串包裹在
json_decode() -
@mulquin 刚刚更新,但仍无法使用 json_decode()
-
下次你可以 var_export($json) 看看它有什么并发现你的错误。这就是调试方式。