Home > Backend Development > PHP Tutorial > PHP tutorial: php captures the content of https_PHP tutorial

PHP tutorial: php captures the content of https_PHP tutorial

WBOY
Release: 2016-07-13 09:50:05
Original
922 people have browsed it

PHP Tutorial: PHP captures the content of https

If you use file_get_contents directly, an error will be reported;

Program code $url = (https://xxx.com");

file_get_contents($url);

Error:

 Program code Warning: file_get_contents(https://xxx.com) [function.file-get-contents]: failed to open stream: No such file or directory in D:wampwwwgrabber_clientindex.php on line 3

It is possible to use curl:

Program code $url = (https://xxx.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);

 ?>

The key points are the following two sentences:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

   Note: For more exciting tutorials, please pay attention to Bangkejia's Design Tutorial column,

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1018375.htmlTechArticlePHP tutorial: php grabs the content of https and uses file_get_contents directly, an error will be reported; Program code $url = (https: //xxx.com); file_get_contents($url); Error: Program code Warning: file_get_con...
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