(PHP 5 >= 5.5.0)
curl_strerror — Returns a description of the error code.
string curl_strerror ( int $errornum )
Returns the text description of the error code.
errornum
A constant for cURL error codes.
Returns error code description information, and returns NULL for illegal error codes.
<?php// Create a cURL handle with a misspelled URL $ch = curl_init("htp://example.com/"); // Send a request curl_exec($ch); // Check the error code and display the error message if($errno = curl_errno($ch)) { $error_message = curl_strerror($errno); echo "cURL error ({$errno}):n {$error_message}";}//Close the handle curl_close($ch);?>
The above routine will output:
cURL error (1): Unsupported protocol