最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
PHP Warning: file_get_contents failed to open stream解决办法
时间:2022-06-24 23:15:16 编辑:袖梨 来源:一聚教程网
在做项目时用 file_get_contents 来获取数据,php 报错 PHP Warning: file_get_contents failed to open stream: no suitable wrapper could be found.
最后用了curl来获取数据!
今天百度了一下!找到了解决办法!先拷贝过来!
系统:centos 6.5
在错误日志中,php报的错误是
Warning: file_get_contents() [function.file-get-contents]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0
failed to open stream: no suitable wrapper could be found
此警告说服务器阻止访问远程文件,修改php.ini
把
allow_url_fopen = Off
allow_url_include = Off
改成
allow_url_fopen = On
allow_url_include = On
重启php-fpm或者重启web服务。
如果还是无法解决 的话
windows下处理方法:
c:windowsphp.ini
extension=php_openssl.dll 把前的;去掉,重启iis服务。
linux下处理方法:
/etc/php.ini
extension=php_openssl.dll 把前的;去掉,重启apache服务。
如果上面问题没能解决我的问题,我们可以如下测试。
$context = stream_context_create(array('http'=>array('ignore_errors'=>true)));
$contents = file_get_contents($url, FALSE, $context);
可以请求时,忽略错误。可以解决警告信息
相关文章
- 如何交易CUDIS币?2025OKX交易所高效攻略 06-16
- 最好用全球交易所加密货币交易榜单-低手续费现货交易所币安推荐 06-16
- 《白荆回廊》玄戈培养有什么 06-16
- SQD币怎么交易-2025币安交易所新手全攻略 06-16
- 《斗罗大陆:武魂觉醒》混沌之子魂骨搭配方案推荐 06-16
- 最火全球交易所数字资产交易TOP10-去中心化比特币交易所币安推荐 06-16