【发布时间】:2015-01-14 14:39:22
【问题描述】:
我有一条路线:
Route::group(array('prefix' => 'playlist'), function()
{
Route::get('raw/{id}', array('as'=>'rawPlaylist', 'uses'=>'PlaylistsController@raw'));
});
当我打开网址时:
http://localhost:8000/playlist/raw/1
一切都很好,页面将加载并向我显示视图。
在控制器中我得到 URL:
$url = URL::route('rawPlaylist', 1);
问题: 我想读取视图并将整个视图存储到一个变量中:
$html = file_get_contents($url);
echo $url 是http://localhost:8000/playlist/raw/1 这是对的。
但这不起作用。我没有得到任何回应,并且 php artisan 服务中断。 为什么?这里有什么问题?
【问题讨论】:
-
请看 url echo $url; ?
-
echo $url 是
http://localhost:8000/playlist/raw/1这是对的。 -
不行:看你的网址localhost:8000/de/playlist/raw/1
-
不断调用同一个url。 file_get_contents($url) 内容持久化连接您的服务器。
-
是的,你是对的。我现在将路线更改为 localhost:8000/playlist/raw/1 .. 而不是 /de/ 。它现在是相同的 URL,但它也不起作用......
标签: php laravel file-get-contents