一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

file_get_contents()获取https出现这个错误Unable to find the wrapper “https”

时间:2016-10-20 编辑:简简单单 来源:一聚教程网

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函数。

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']);
?>

检查主机是否支持php的file_get_contents函数

讲一下代码存储为php文件,在空间运行,即可得出结果。

echo ‘Curl: ‘, function_exists(‘curl_version’) ? ‘Enabled’ : ‘Disabled’ . ‘

file_get_contents: ‘, file_get_contents(__FILE__) ? ‘Enabled’ : ‘Disabled’;
?>
 

热门栏目