[英]Trying to get property of non-object in (PHP)
get error message:获取错误信息:
Notice: Trying to get property of non-object in C:\\xampp\\htdocs\\test.php on line 11注意:第 11 行尝试在 C:\\xampp\\htdocs\\test.php 中获取非对象的属性
This is my code:这是我的代码:
<?php
$json_url = "http://samp-stats.ru/web/api-12492.js";
$json = file_get_contents($json_url);
$data = json_decode($json);
echo "<pre>";
var_dump($json);
echo "</pre>";
for ($i = 0; $i < count($data->plinfo); $i++) {
$document->write($data->plinfo[$i]->name + ' - ' + $data->plinfo[$i]->score + '<br>');
}
?>
The JSON is incorrectly formatted. JSON 格式不正确。
var api =
at the beginning.所以去掉开头的var api =
。ip:'37.59.30.67'
needs to read "ip":"37.59.30.67"
所以ip:'37.59.30.67'
需要读取"ip":"37.59.30.67"
{name:'Mariu$Bahaos',score:'48' }, ]
. {name:'Mariu$Bahaos',score:'48' }, ]
。 That trailing comma tells the parser to expect another object in the array.尾随逗号告诉解析器期待数组中的另一个对象。}
is the end character for a JSON string. }
是 JSON 字符串的结束字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.