Home > Backend Development > PHP Tutorial > How to use curl to open https website in php_PHP tutorial

How to use curl to open https website in php_PHP tutorial

WBOY
Release: 2016-07-13 09:50:29
Original
1424 people have browsed it

How to use curl to open an https website in PHP

This article mainly introduces how to use curl to open an https website in PHP, and involves related techniques of using curl in PHP to connect to the website and obtain information. , friends in need can refer to it

The example in this article describes how to use curl to open an https website in PHP. Share it with everyone for your reference. The specific implementation method is as follows:

 ?

 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;

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1017845.htmlTechArticleHow to use curl to open https website in php. This article mainly introduces how to use curl to open https website in php, involving PHP uses curl to connect to the website and obtain information related skills, friends who need it...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template