Easy Tutorial
❮ Func Math Dechex Func String Strnatcmp ❯

PHP curl_strerror Function

PHP cURL Reference Manual

(PHP 5 >= 5.5.0)

curl_strerror — Returns the description of the error code.


Description

string curl_strerror ( int $errornum )

Returns the text description of the error code.


Parameters

errornum

A constant corresponding to a » cURL error code.


Return Value

Returns the error code description, or NULL for an invalid error code.


Example

<?php
// Create a cURL handle with a misspelled URL
$ch = curl_init("htp://example.com/");

// Send the request
curl_exec($ch);

// Check for error code and display 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 example will output:

cURL error (1):
 Unsupported protocol

PHP cURL Reference Manual

❮ Func Math Dechex Func String Strnatcmp ❯