English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
(PHP 4 >= 4.0.4, PHP 5)
curl_getinfo — Get information about a CURL connection resource handle
mixed curl_getinfo ( resource $ch[, int $opt = 0 ] )
Get information about the last transfer.
ch
The CURL handle returned by curl_init().
opt
This parameter may be one of the following constants:
CURLINFO_EFFECTIVE_URL - The last valid URL address
CURLINFO_HTTP_CODE - The last received HTTP code
CURLINFO_FILETIME - Time taken to remotely retrieve the document, if it cannot be retrieved, the returned value is "-1"
CURLINFO_TOTAL_TIME - Time consumed in the last transfer
CURLINFO_NAMELOOKUP_TIME - Time consumed in name resolution
CURLINFO_CONNECT_TIME - Time consumed in establishing the connection
CURLINFO_PRETRANSFER_TIME - Time used from establishing the connection to preparing the transfer
CURLINFO_STARTTRANSFER_TIME - Time used from establishing the connection to the start of the transfer
CURLINFO_REDIRECT_TIME - Time used for redirection before the transaction transfer starts
CURLINFO_SIZE_UPLOAD - Total amount of uploaded data
CURLINFO_SIZE_DOWNLOAD - Total amount of downloaded data
CURLINFO_SPEED_DOWNLOAD - Average download speed
CURLINFO_SPEED_UPLOAD - Average upload speed
CURLINFO_HEADER_SIZE - The size of the header part
CURLINFO_HEADER_OUT - The string sent with the request
CURLINFO_REQUEST_SIZE - The size of the problematic request in an HTTP request
CURLINFO_SSL_VERIFYRESULT - By settingCURLOPT_SSL_VERIFYPEERReturns the result of the SSL certificate verification request
CURLINFO_CONTENT_LENGTH_DOWNLOAD - FromContent-Length: Field read by the downloaded content length
CURLINFO_CONTENT_LENGTH_UPLOAD - Description of upload content length
CURLINFO_CONTENT_TYPE - Downloaded contentContent-Type:Value, NULL indicates that the server did not send validContent-Type: Header
If opt is set, return its value as a string. Otherwise, return an associative array containing the following elements (they correspond to opt):
"url"
"content_type"
"http_code"
"header_size"
"request_size"
"filetime"
"ssl_verify_result"
"redirect_count"
"total_time"
"namelookup_time"
"connect_time"
"pretransfer_time"
"size_upload"
"size_download"
"speed_download"
"speed_upload"
"download_content_length"
"upload_content_length"
"starttransfer_time"
"redirect_time"
Version | Description |
---|---|
5.1.3 | IncludeCURLINFO_HEADER_OUT . |
<?php // Create a CURL handle $ch = curl_init('http:');//www.oldtoolbag.com/'); // Execute curl_exec($ch); // Check if an error has occurred if(!curl_errno($ch)) { $info = curl_getinfo($ch); echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url']; } //Close handle curl_close($ch); ?>