Home >Backend Development >PHP Tutorial >PHP tutorial: php captures the content of https_PHP tutorial
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,