English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

Usage and examples of PHP curl_strerror() function

PHP CURL Reference Manual

(PHP 5 >= 5.5.0)

curl_strerror — Returns the description of the error code.

Syntax

string curl_strerror ( int $errornum )

Returns the text description information of the error code.

Parameter

errornum

One » CURL Error CodesConstants.

Return value

Returns error code description information, returns NULL for illegal error codes.

Online example

<?php
// Create a CURL handle with a misspelled URL
$ch = curl_init("htp://example.com/");
// Send request
curl_exec($ch);
// Check error code and display error information
if($errno = curl_errno($ch)) {
    $error_message = curl_strerror($errno);
    echo "CURL error ({$errno}):\n {$error_message}";
}
// Close handle
curl_close($ch);
?>

The following example will output:

CURL error (1):
 Unsupported protocol

PHP CURL Reference Manual