我该如何解决这个错误.
file_get_contents(http://www.example.com/name/j/92801): failed to open stream: HTTP request failed! HTTP/1.1 416 Requested Range Not Satisfiable in line
这是php文件代码.
echo $file = file_get_contents("http://www.example.com/name/j/92801");
我正在使用wamp服务器2.4
小智 1
首先allow_url_fopen在你的 php.ini 文件中启用了吗?其次,最好使用 CURL 这里有一个小函数可以帮助你
function curl($url , $ua = FALSE){
if($ua == false){
$ua = $_SERVER['HTTP_USER_AGENT'];
}
$ch = curl_init();
curl_setopt($ch , CURLOPT_URL , $url);
curl_setopt($ch , CURLOPT_RETURNTRANSFER , true);
curl_setopt($ch , CURLOPT_FOLLOWLOCATION , true);
curl_setopt($ch , CURLOPT_USERAGENT , $ua);
return curl_exec($ch);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1345 次 |
| 最近记录: |