调用http_curl类,$res返回NULL怎么办
public function http_curl($url='',$type='',$res='',$arr=''){
//获取**,初始化curl
$ch = curl_init();
//设置curl参数
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//curopt_returntransfer
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,FALSE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
if($type == 'post'){
curl_setopt($ch, CURLOPT_PORT, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $arr);
}
//采集(调用接口)
$output = curl_exec($ch);
//关闭
curl_close($ch);
if($res == 'json'){
if(curl_errno($ch)){
return curl_error($ch);
}else{
return json_decode($output,true);
}
}
//var_dump($output);
}