1. 程式人生 > >file_get_contents()獲取https出現這個錯誤Unable to find the wrapper “https” – did

file_get_contents()獲取https出現這個錯誤Unable to find the wrapper “https” – did

AC ans html 解決 itl follow htm erer -c

file_get_contents()獲取https出現這個錯誤Unable to find the wrapper “https” – did

解決辦法一,如果你是用的服務器,可以參考這個辦法,修改php配置文件(win主機),來支持https

在php.ini中找到並修改



extension=php_openssl.dll
    allow_url_include = On


重啟服務就可以了,如果你的是linux服務器,linux下的PHP,就必須安裝openssl模塊,安裝好了以後就可以訪了。

解決辦法二,如果你用的不是服務器,你用的主機,你沒法更改php的配置,你可以通過使用curl函數來替代file_get_contents函數,當然你的主機必須支持curl函數。

<?php

function getSslPage($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE
); $result = curl_exec($ch); curl_close($ch); return $result; } echo getSslPage($_GET[‘url‘]); ?>

file_get_contents()獲取https出現這個錯誤Unable to find the wrapper “https” – did