PHP curl_strerror Function
(PHP 5 >= 5.5.0)
curl_strerror — Return the description of an error code.
Description
string curl_strerror ( int $errornum )
Returns the text description of an error code.
Parameters
errornum
A» cURL error codeconstant.
Return Values
Returns the error code description, or NULL for invalid error codes.
Examples
<?php
// 创建一个拼写错误的URL的cURL句柄
$ch = curl_init("htp://example.com/");
// 发送请求
curl_exec($ch);
// 检查错误代码并显示错误信息
if($errno = curl_errno($ch)) {
$error_message = curl_strerror($errno);
echo "cURL error ({$errno}):\n {$error_message}";
}
// 关闭句柄
curl_close($ch);
?>
The above example will output:
cURL error (1): Unsupported protocol
Other Extensions
PHP cURL Reference Manual