默认值错了?
protected function http_curl($url, $arr = '', $type = 'get', $res = 'json')
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if ($type == 'post') {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $arr);
}
$output = curl_exec($ch);
if ($res == 'json') {
if ($err = curl_errno($ch)) {
//要在关闭之前获得curl_errno
curl_close($ch);
return $err;
} else {
return json_decode($output, true);
}
}
}