How to use curl_errno() and curl_error() to get the error number for the last cURL operation in PHP

1 Answer

0 votes
$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, "http://www.nowebsiteexisthere.com/");
curl_setopt($curl, CURLOPT_HEADER, 0);

// pass the URL to the browser
curl_exec($curl);

if(curl_errno($curl))
{
    echo 'Curl error message: ' . curl_error($curl);
}

curl_close($curl);


/*
run: 

Curl error message: Could not resolve host: www.nowebsiteexisthere.com 

*/

 



answered Jun 7, 2016 by avibootz
...