curl_exec($ch)的返回值一直是false,调用curl_errno($ch)是空的???
public function http_curl($url,$type='get',$res='json',$arr=''){
// 初始化
$ch=curl_init();
// 设置参数
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_HEADER,FALSE);
if($type == 'post'){
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$arr);
}
$output=curl_exec($ch);
curl_close($ch);
var_dump($output);
echo 'error:'.curl_errno($ch);
if(curl_errno($ch)){
var_dump(curl_errno($ch));
}
if($res == 'json'){
return json_decode($output,true);
}
return $output;
}