PHP curl timeout error detection

前端 未结 2 496
猫巷女王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: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);
    }
    

提交回复
热议问题