<menu id="ocigx"><listing id="ocigx"><em id="ocigx"></em></listing></menu><em id="ocigx"><track id="ocigx"><strong id="ocigx"></strong></track></em>
<ins id="ocigx"></ins>

<samp id="ocigx"></samp>

<mark id="ocigx"><ruby id="ocigx"><legend id="ocigx"></legend></ruby></mark><bdo id="ocigx"></bdo>
      <kbd id="ocigx"></kbd>
      首頁 > 開發 > Php > 正文

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

      2020-06-09 12:33:55
      字體:
      來源:轉載
      供稿:網友

      在做項目時用 file_get_contents 來獲取數據,php 報錯  PHP Warning: file_get_contents failed to open stream: no suitable wrapper could be found.

      最后用了curl來獲取數據!

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

      系統:centos 6.5

      在錯誤日志中,php報的錯誤是:

      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 

      此警告說服務器阻止訪問遠程文件,修改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服務。

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

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

      發表評論 共有條評論
      用戶名: 密碼:
      驗證碼: 匿名發表