2014-01-27 160 views
2

以下代码始终回显false。我错过了什么吗?curl始终返回false

$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"; 
} 
+0

的[读SSL页面CURL(PHP)]可能重复(http://stackoverflow.com/questions/521418/reading-ssl-page-with-curl-php) –

+0

'回声卷曲错误:'。 curl_error($ ch);'在这种情况下调试可能很有用。 –

回答

2

添加此cURL PARAM。这是因为Google运行在安全HTTP上。

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
+0

编辑完答案后,它就起作用了。 – Nfear