国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

PHP Warning: file_get_contents failed to open stream解決辦法

2024-05-04 21:50:28
字體:
供稿:網(wǎng)友

在做項(xiàng)目時用 file_get_contents 來獲取數(shù)據(jù),php 報(bào)錯  PHP Warning: file_get_contents failed to open stream: no suitable wrapper could be found.

最后用了curl來獲取數(shù)據(jù)!

今天百度了一下!找到了解決辦法!先拷貝過來!

系統(tǒng):centos 6.5

在錯誤日志中,php報(bào)的錯誤是:

  1. Warning: file_get_contents() [function.file-get-contents]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 
  2.  
  3. failed to open stream: no suitable wrapper could be found 

此警告說服務(wù)器阻止訪問遠(yuǎn)程文件,修改php.ini

把:

allow_url_fopen = Off

allow_url_include = Off

改成:

allow_url_fopen = On

allow_url_include = On

重啟php-fpm或者重啟web服務(wù)。

如果還是無法解決的話

windows下處理方法:

c:/windows/php.ini

extension=php_openssl.dll 把前的;去掉,重啟iis服務(wù)。

linux下處理方法:

/etc/php.ini

extension=php_openssl.dll 把前的;去掉,重啟apache服務(wù)。

如果上面問題沒能解決我的問題,我們可以如下測試。

  1. $context = stream_context_create(array('http'=>array('ignore_errors'=>true))); 
  2. $contents = file_get_contents($url, FALSE, $context); 
可以請求時,忽略錯誤。可以解決警告信息

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 丹棱县| 铜山县| 乐都县| 蚌埠市| 余干县| 中牟县| 长丰县| 平顺县| 昭觉县| 科技| 彭阳县| 浑源县| 牙克石市| 兴国县| 凤阳县| 宁武县| 金坛市| 平阴县| 桂平市| 荣成市| 石城县| 大新县| 安丘市| 峨眉山市| 乌兰浩特市| 句容市| 涪陵区| 女性| 库尔勒市| 南安市| 南京市| 双鸭山市| 烟台市| 东丽区| 巴里| 盈江县| 达孜县| 邯郸市| 子洲县| 永吉县| 安陆市|