PHP头条
热点:

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


   这篇文章主要介绍了php使用curl打开https网站的方法,涉及php使用curl连接网站及获取信息的相关技巧,需要的朋友可以参考下

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

  ?

  1

  2

  3

  4

  5

  6

  7

  8

  9

  10

  11$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程序设计有所帮助。

www.phpzy.comtrue/php/26710.htmlTechArticlephp使用curl打开https网站的方法 这篇文章主要介绍了php使用curl打开https网站的方法,涉及php使用curl连接网站及获取信息的相关技巧,需要的朋友可以参考下 本文实例讲述了php使用curl打开...

相关文章

    暂无相关文章

PHP之友评论

今天推荐