php curl请求超时处理

 $res = curl_exec($ch);
/* if ($no = curl_errno($ch)) {
     curl_close($ch);
     //$no错误码7为连接不上,28为连接上了但请求返回结果超时
     if(in_array(intval($no), [7, 28], true)) {
         return false;// 或者抛出异常自行捕获throw  new Exception("请求超时");
     }
 }*/
 curl_close($ch);

猜你喜欢

转载自blog.csdn.net/dw5235/article/details/107152546