2

The following code always echos false. Am I missing something?

$url = "https://www.google.nl/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if(curl_exec($ch)) {
    echo "true";
}else{
    echo "false";
}
stefana
  • 2,606
  • 3
  • 29
  • 47
  • possible duplicate of [reading SSL page with CURL (php)](http://stackoverflow.com/questions/521418/reading-ssl-page-with-curl-php) – Amal Murali Jan 27 '14 at 09:25
  • `echo 'Curl error: ' . curl_error($ch);` could be useful for debugging in situations like this. – Amal Murali Jan 27 '14 at 09:26

1 Answers1

2

Add this cURL param. That is because , Google runs on Secure HTTP.

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126