所以我有下面的代码:
<?PHP
$remote_url = 'https://www.haloapi.com/stats/h5/players/PLAYER/matches';
// Create a stream
$opts = array(
'http'=>array(
'method'=>"GET",
'header' => "Ocp-Apim-Subscription-Key: MY SUBSCRIPTION KEY")
);
$context = stream_context_create($opts);
// Open the file using the HTTP headers set above
$file = file_get_contents($remote_url, false, $context);
print(json_decode($file));
?>它给出了以下错误:
可捕获的致命错误:无法在第17行将类stdClass的对象转换为C:\xampp\htdocs\HaloAPItest\index.php中的字符串
我做什么好?
发布于 2016-02-04 07:32:50
达伦在他的评论中说的话。print_r可以处理任何类的变量。只打印字符串。
另一个有用的函数是var_dump。编写一个像var_dump_pre这样的函数并让它在输出周围放置<pre> </pre>标记也是很好的。在屏幕上很好地格式化它。
https://stackoverflow.com/questions/35189538
复制相似问题