国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 邯郸市| 开平市| 错那县| 手机| 都匀市| 辽源市| 莲花县| 贺兰县| 清原| 迁西县| 淳化县| 泽普县| 常熟市| 库尔勒市| 潢川县| 湖北省| 蒙山县| 金塔县| 淮滨县| 宁南县| 广河县| 任丘市| 龙泉市| 沐川县| 贵德县| 札达县| 隆昌县| 云和县| 巴中市| 任丘市| 根河市| 祁东县| 喀什市| 武邑县| 湖南省| 普兰县| 保德县| 丁青县| 米林县| 巴马| 子长县|