教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 PHP Warning: file_get_contents failed to open stream解决办法

PHP Warning: file_get_contents failed to open stream解决办法

发布时间:2017-12-12   编辑:jiaochengji.com
教程集为您提供PHP Warning: file,get,contents failed to open stream解决办法等资源,欢迎您收藏本站,我们将为您提供最新的PHP Warning: file,get,contents failed to open stream解决办法资源
file_get_contents函数在获得远程文件时提示Warning: file_get_contents failed to open stream,希望例子能够帮助到各位,希望例子能够帮助到大家。

在做项目时用 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:\windows\php.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);

可以请求时,忽略错误。可以解决警告信息

您可能感兴趣的文章:
PHP Warning: file_get_contents failed to open stream解决办法
解决:failed to open stream: No such file or directory in
php file_get_contents抓取https地址报错的解决办法
php include提示failed to open stream: Permission denied in错误
phpmyamdin安装出现Warning: require(./libraries/Error_Handler.class.php) 错误解决办法
file_get_contents 中文路径报错问题解决
php抓取https内容的方法
failed to open stream: HTTP request failed!
php 获取远程网页内容简单函数
PHP date()函数It is not safe to rely on the system s timezone settings

[关闭]
~ ~