How to catch curl errors in PHP

 

generate curl error after its execution


$url = 'http://example.com';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
if(curl_errno($ch)){
    echo 'Request Error:' . curl_error($ch);
}


source :#https://stackoverflow.com/questions/3987006/how-to-catch-curl-errors-in-php