当前位置:首页 > PHP教程 > PHP高级教程

php使用curl打开https网站的方法

本文实例讲述了php使用curl打开https网站的方法。分享给大家供大家参考。具体实现方法如下:

$url = 'https://www.google.com.hk'; 
$ch = curl_init(); 
curl_setopt($ch, curlopt_url, $url); 
curl_setopt($ch, curlopt_header, false); 
curl_setopt($ch, curlopt_returntransfer, true); 
curl_setopt($ch, curlopt_ssl_verifypeer, false); 
curl_setopt($ch, curlopt_useragent, 'mozilla/5.0 (windows nt 6.1) applewebkit/537.11 (khtml, like gecko) chrome/23.0.1271.1 safari/537.11'); 
$res = curl_exec($ch); 
$rescode = curl_getinfo($ch, curlinfo_http_code);  
curl_close($ch) ; 
echo $res;

希望本文所述对大家的php程序设计有所帮助。


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!