PHP curl timeout error detection

前端 未结 2 497
猫巷女王i
猫巷女王i 2021-01-01 09:30

I use curl to perform a HTTP request like this:

$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1)         


        
相关标签:
2条回答
  • 2021-01-01 09:53

    Use curl_errno()

    Code 28 is timeout.

    0 讨论(0)
  • 2021-01-01 09:55

    you can check error number and its' description like this:

    // Check if any error occurred
    if(curl_errno($ch))
    {
        echo 'Curl error: ' . curl_error($ch);
    }
    
    0 讨论(0)
提交回复
热议问题