您的位置首页百科知识

file_get_contents出现错误的解决办法

file_get_contents出现错误的解决办法

的有关信息介绍如下:

file_get_contents出现错误的解决办法

file_get_contents()获取https出现Unable to find the wrapper “https” – did错误的解决办法

打开php.ini文件,extension=php_openssl.dll去掉前面的分号,allow_url_include = off改为allow_url_include = On,然后重启服务就可以了。如图

或者也可以通过使用curl函数来替代file_get_contents函数,当然php.ini打开了curl,extension=php_curl.dll,如图

最后分享个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']);?>