我正在尝试从我的 Laravel 项目中的页面获取 JSON 字符串。使用这个:
$json = file_get_contents($url);
$data = json_decode($json, TRUE);
return View::make('adventuretime.marceline')
->with('json', $json)
->with('title', 'ICE KING')
->with('description', 'I am the Ice King')
->with('content', 'ice king');
但由于我只使用本地主机,我认为这不起作用,这就是它不输出任何内容的原因。我想知道什么是让它灵活并能够使用 php 获取具有任何 $url 值的 JSON 字符串的正确方法是什么?