检查PHP curl请求是否已超时

时间:2018-03-05 10:21:23

标签: php curl timeout

我正在尝试检查对API的调用是否已超时。我尝试在给定的网址中添加额外的端口,例如:google.com:81。

我也尝试使用if(curl_errno($ curl)),但似乎并非如此。

如何实现这样的目标?

$Voornamen = array( '0300013' => "Laurence" , '0266931' => "Peter" , '0267730' => "Pim" , '0279410' => "Arben" , '0297652' => "Robbin" , '0300838' => "Damian");
  $Achternamen = array( '0300013' => "Van der Wel" , '0266931' => "Kuipers" , '0267730' => "Hoomans" , '0279410' => "Hajrizaj" , '0297652' => "Visser" , '0300838' => "Trojak");
  $Woonplaatsen = array( '0300013' => "Enschede" , '0266931' => "Enschede" , '0267730' => "Enschede" , '0279410' => "Enschede" , '0297652' => "Overdinkel" , '0300838' => "Enschede");
  $Leeftijden = array( '0300013' => "17" , '0266931' => "20" , '0267730' => "20" , '0279410' => "19" , '0297652' => "16" , '0300838' => "16");

  //$persoon = array_rand($voornaam, 1);

  $arr = array($Voornamen,$Achternamen,$Woonplaatsen,$Leeftijden);
multi_array($arr);
function multi_array($array){
  foreach ($array as $key => $val){
      foreach($val as $v) {
        echo "<table>
            <tr>
              <td>
                $v
                </td>
            </tr>               
          </table>";
      }
  }
}

感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

你可以找到一个cURL错误列表here,你所追求的错误是public static void main(String args[]){ int first = 1; int second = 3; int third = 5; int n = 5; int sum = 0; for(int i=0;i<n;i++){ sum+=first*second*third; first++; second+=2; third+=3; } }

PHP有一个名为curl_errno(resource $ch)的方法,您可以使用它来获取错误号。了解这两个方面,您可以执行以下操作:

CURLE_OPERATION_TIMEDOUT (28)

如果仍然无效,那么您可能需要查看curl_error(resource $ch)获得的实际卷曲错误,并提供更多信息以便我们提供帮助。