完美解决failed to open stream: HTTP request failed!
2012-11-21 20:32
615 查看
当使用php5自带的file_get_contents方法来获取远程文件的时候(在我的自动化测试框架中有类似调用需求),有时候会出现file_get_contents(): failed to open stream: HTTP request failed!这个警告信息。
解决的方法都是修改php.ini,把allow_url_fopen给启用,改成 allow_url_fopen = On
这样做可以解决某些人的问题,有人说在php.ini中,有这样两个选项:allow_url_fopen =on(表示可以通过url打开远程文件),user_agent="PHP"(表示通过哪种脚本访问网络,默认前面有个 " ; " 去掉即可。)重启服务器。
但是有些还是会有这个警告信息,想用完美的解决还差一步,还得设置php.ini里面的user_agent,php默认的user_agent是 PHP,我们把它改成Mozilla/4.0 (compatible; MSIE 6.0;Windows NT 5.0)来模拟浏览器就可以了,user_agent=”Mozilla/4.0 (compatible; MSIE 6.0; Windows
NT 5.0)”
解决的方法都是修改php.ini,把allow_url_fopen给启用,改成 allow_url_fopen = On
这样做可以解决某些人的问题,有人说在php.ini中,有这样两个选项:allow_url_fopen =on(表示可以通过url打开远程文件),user_agent="PHP"(表示通过哪种脚本访问网络,默认前面有个 " ; " 去掉即可。)重启服务器。
但是有些还是会有这个警告信息,想用完美的解决还差一步,还得设置php.ini里面的user_agent,php默认的user_agent是 PHP,我们把它改成Mozilla/4.0 (compatible; MSIE 6.0;Windows NT 5.0)来模拟浏览器就可以了,user_agent=”Mozilla/4.0 (compatible; MSIE 6.0; Windows
NT 5.0)”
相关文章推荐
- 完美解决failed to open stream: HTTP request failed!(file_get_contents引起的)
- php错误提示failed to open stream: HTTP request failed!的完美解决方法
- 完美解决failed to open stream: HTTP request failed!(file_get_contents引起的)
- php错误提示failed to open stream: HTTP request failed!的完美解决方法
- 【分享】完美解决failed to open stream: HTTP request failed!
- 完美解决failed to open stream: HTTP request failed!(file_get_contents引起的)
- 完美解决failed to open stream: HTTP request failed!
- 完美解决failed to open stream: HTTP request failed!(file_get_contents引起的)
- 完美解决failed to open stream: HTTP request failed!
- 完美解决failed to open stream: HTTP request failed!(file_get_contents引起的)
- 解决failed-to-open-stream:-HTTP-request-failed!
- php file_get_contents失败[function.file-get-contents]: failed to open stream: HTTP request failed!解决
- 解决failed to open stream: HTTP request failed!
- PHP解决[function.file-get-contents]: failed to open stream: HTTP request failed!
- php错误:failed to open stream: HTTP request failed!
- PHP问题 —— failed to open stream: HTTP request faile
- PHP问题 —— failed to open stream: HTTP request faile
- php file_get_contents()报错 failed to open stream: HTTP request failed!、Internal Server Error
- php错误提示failed to open stream: HTTP request failed!