file_get_contents 得到https类型url失败的方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/terry_water/article/details/39377255

把file_get_contents改成下面的方法即可:


function getSSLPage($url) {
    $ch = curl_init();
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSLVERSION,30); 
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}


没有更多推荐了,返回首页