1

curl is enabled in my XAMPP installation. But my following code returns a blank page:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.google.com/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

print $response;

1 Answer  正确答案

1

use curl_setopt($link, CURLOPT_SSL_VERIFYPEER, FALSE); to resolve your issue

<?php
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://www.google.com/"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($link, CURLOPT_SSL_VERIFYPEER, FALSE); // to resolve your current error $response = curl_exec($ch); if (curl_error($ch)) {    $error_msg = curl_error($ch);    var_dump($error_msg);exit; } curl_close($ch); var_dump($response);






Note:- The above can come with security issue, so exactly fix this issue try to run below command in your system:

/bin/chmod 755 /etc/pki/tls/certs

Reference:- How to fix the Curl Error: error setting certificate verify locations

Your Answer