我有這樣的功能:curl_exec總是返回0?
function Connect($url, $post = 0, $postfields = '')
{
$ch = curl_init();
if($post > 0) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
}
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/joomla-cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'/joomla-cookie.txt');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$exec = curl_exec($ch);
if($exec) { return $exec; } else { return 0; }
}
我這樣稱呼它是Connect($host)
,它總是返回0 ...
'$ host'建議您發送「google.com」,其中所需的url爲'http:// google.com',你在用什麼? – 2011-06-08 22:57:39
@Sabeen我用https:// 實際發送它也許是因爲https://而不是http://? cuz「http://www.google.com」的作品。 – Danpe 2011-06-08 23:05:19