PHP curl_error Function
(PHP 4 >= 4.0.3, PHP 5)
curl_error — Returns a string containing the last error for the current session.
Description
string curl_error ( resource $ch )
Returns a clear text error message for the last cURL operation.
Parameters
ch
The cURL handle returned by curl_init().
Return Values
Returns the error message or '' (empty string) if no error occurred.
Examples
<?php
// 创建一个指向一个不存在的位置的cURL句柄
$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 '操作完成没有任何错误';
}
// 关闭句柄
curl_close($ch);
?>
See Also
- curl_errno()- Returns the last error number
- » Curl error codes
Other Extensions
PHP cURL Reference Manual