curl_errno() - 返回最后一次的错误代码 - curl函数库
curl_errno()
(PHP 4 >= 4.0.3, PHP 5, PHP 7)
返回最后一次的错误代码
说明
curl_errno(resource $ch): int返回最后一次 cURL 操作的错误代码。
参数
$ch由curl_init()返回的 cURL 句柄。
返回值
返回错误代码或在没有错误发生时返回0(零)。
范例
curl_errno()例子
参见
curl_error()
返回当前会话最后一次错误的字符串- » Curl 错误代码
if someone need more information about curl errors
To coder.ua[at]gmail.com: Please note some errors have more than one constants: [CURLE_FTP_PARTIAL_FILE] 18 [CURLE_PARTIAL_FILE] 18 [CURLE_HTTP_NOT_FOUND] 22 [CURLE_HTTP_RETURNED_ERROR] 22 [CURLE_OPERATION_TIMEDOUT] 28 [CURLE_OPERATION_TIMEOUTED] 28 [CURLE_BAD_DOWNLOAD_RESUME] 36 [CURLE_FTP_BAD_DOWNLOAD_RESUME] 36
Note that you can detect errors using curl_multi_info_read() in the curl_multi_exec() loop that don't show up later using curl_errno(). This seems particularly true of connection errors.
you should look on http://php.net/manual/en/curl.constants.php for the error codes, not on the linked official curl doc. some of the error codes are different, at least the one mentioned on the other page: in PHP the curl error number 28 is called CURLE_OPERATION_TIMEOUTED while in the official site is: CURLE_OPERATION_TIMEDOUT
All available curl error constants and values in PHP 5.4.7 on FreeBSD 8.2-RELEASE: CURLE_UNSUPPORTED_PROTOCOL => 1 CURLE_FAILED_INIT => 2 CURLE_URL_MALFORMAT => 3 CURLE_URL_MALFORMAT_USER => 4 CURLE_COULDNT_RESOLVE_PROXY => 5 CURLE_COULDNT_RESOLVE_HOST => 6 CURLE_COULDNT_CONNECT => 7 CURLE_FTP_WEIRD_SERVER_REPLY => 8 CURLE_FTP_ACCESS_DENIED => 9 CURLE_FTP_USER_PASSWORD_INCORRECT => 10 CURLE_FTP_WEIRD_PASS_REPLY => 11 CURLE_FTP_WEIRD_USER_REPLY => 12 CURLE_FTP_WEIRD_PASV_REPLY => 13 CURLE_FTP_WEIRD_227_FORMAT => 14 CURLE_FTP_CANT_GET_HOST => 15 CURLE_FTP_CANT_RECONNECT => 16 CURLE_FTP_COULDNT_SET_BINARY => 17 CURLE_PARTIAL_FILE => 18 CURLE_FTP_COULDNT_RETR_FILE => 19 CURLE_FTP_WRITE_ERROR => 20 CURLE_FTP_QUOTE_ERROR => 21 CURLE_HTTP_NOT_FOUND => 22 CURLE_WRITE_ERROR => 23 CURLE_MALFORMAT_USER => 24 CURLE_FTP_COULDNT_STOR_FILE => 25 CURLE_READ_ERROR => 26 CURLE_OUT_OF_MEMORY => 27 CURLE_OPERATION_TIMEOUTED => 28 CURLE_FTP_COULDNT_SET_ASCII => 29 CURLE_FTP_PORT_FAILED => 30 CURLE_FTP_COULDNT_USE_REST => 31 CURLE_FTP_COULDNT_GET_SIZE => 32 CURLE_HTTP_RANGE_ERROR => 33 CURLE_HTTP_POST_ERROR => 34 CURLE_SSL_CONNECT_ERROR => 35 CURLE_FTP_BAD_DOWNLOAD_RESUME => 36 CURLE_FILE_COULDNT_READ_FILE => 37 CURLE_LDAP_CANNOT_BIND => 38 CURLE_LDAP_SEARCH_FAILED => 39 CURLE_LIBRARY_NOT_FOUND => 40 CURLE_FUNCTION_NOT_FOUND => 41 CURLE_ABORTED_BY_CALLBACK => 42 CURLE_BAD_FUNCTION_ARGUMENT => 43 CURLE_BAD_CALLING_ORDER => 44 CURLE_HTTP_PORT_FAILED => 45 CURLE_BAD_PASSWORD_ENTERED => 46 CURLE_TOO_MANY_REDIRECTS => 47 CURLE_UNKNOWN_TELNET_OPTION => 48 CURLE_TELNET_OPTION_SYNTAX => 49 CURLE_OBSOLETE => 50 CURLE_SSL_PEER_CERTIFICATE => 51 CURLE_GOT_NOTHING => 52 CURLE_SSL_ENGINE_NOTFOUND => 53 CURLE_SSL_ENGINE_SETFAILED => 54 CURLE_SEND_ERROR => 55 CURLE_RECV_ERROR => 56 CURLE_SHARE_IN_USE => 57 CURLE_SSL_CERTPROBLEM => 58 CURLE_SSL_CIPHER => 59 CURLE_SSL_CACERT => 60 CURLE_BAD_CONTENT_ENCODING => 61 CURLE_LDAP_INVALID_URL => 62 CURLE_FILESIZE_EXCEEDED => 63 CURLE_FTP_SSL_FAILED] => 64
/!\ ATTENTION if you are using curl multi handles This function returns 0 in error conditions when run on curl handles accessed via curl_multi_info_read(). You must look at the data returned by curl_multi_info_read() for the true errno. The data is over there instead.
Gets a current list of all CURLE_* error constants, their applicable error messages, and their applicable error codes. Useful for making wrapper classes or for mapping cURL errors to specific Exception objects.
内容声明:本文中引用的各种信息及资料(包括但不限于文字、数据、图表及超链接等)均来源于该信息及资料的相关主体(包括但不限于公司、媒体、协会等机构)的官方网站或公开发表的信息。部分内容参考包括:(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供参考使用,不准确地方联系删除处理!本站为非盈利性质站点,本着为中国教育事业出一份力,发布内容不收取任何费用也不接任何广告!)