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

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP curl_error() Function Usage and Examples

PHP CURL Reference Manual

(PHP 4 >= 4.0.3, PHP 5)

curl_error — Returns a string that protects the last error of the current session

Syntax

string curl_error ( resource $ch )

Returns a clear text error message from the last CURL operation.

Parameters

ch

The CURL handle returned by curl_init().

Return Value

Returns an error message or '' (empty string) if no error occurs.

Online Examples

<?php
// Create a CURL handle pointing to a non-existent location
$ch = curl_init('http://404.php.net/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if(curl_exec($ch) === false)
{
    echo 'Curl error: ' . curl_error($ch);
}
else
{
    echo 'Operation completed without any errors';
}
// Close handle
curl_close($ch);
?>

Related References

PHP CURL Reference Manual