PHP curl detección de errores de tiempo de espera
Uso curl para realizar una solicitud HTTP como esta:
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
¿Cómo puedo comprobar si se ha producido un error y si se trata de un error de tiempo de espera?
27
Author: Mark Amery, 2012-08-08
2 answers
Uso curl_errno()
El código 28 es tiempo de espera.
33
Author: Jason McCreary,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-08-08 15:28:33
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-08-08 15:28:33
Puede comprobar el número de error y su descripción de esta manera:
// Check if any error occurred
if(curl_errno($ch))
{
echo 'Curl error: ' . curl_error($ch);
}