PHP获取https下的内容
作者:不详, 来源:网络, 阅读:123, 发布时间:2014-05-19
直接用file_get_contents
以下是PHP代码:【复制代码】 $url = ("https://goalercn.com");
file_get_contents($url); 报错:
Warning: file_get_contents(
https://goalercn.com) [function.file-get-contents]: failed to open stream: No such file or directory in D:wampwwwgrabber_clientindex.php on line 3
用curl的方式是可以的
以下是PHP代码:【复制代码】 $url = (https://goalercn.com);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$result = curl_exec($ch);
print_r($result); 重点是以下两句:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);