PHP curl_strerror函數
(PHP 5 >= 5.5.0)
curl_strerror — 返回錯誤碼的描述。
說明
string curl_strerror ( int $errornum )
返回錯誤碼的文本描述資訊。
參數
errornum
一個 » cURL 錯誤碼的常量。
返回值
返回錯誤碼描述資訊,非法錯誤碼返回NULL 。
實例
<?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);
?>
以上例程會輸出:
cURL error (1): Unsupported protocol

PHP cURL參考手冊