(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 HTTP code received
CURLINFO_FILETIME - The time when the document was retrieved remotely. If it cannot be retrieved, the return value is "-1"
CURLINFO_TOTAL_TIME - Time spent on the last transfer
CURLINFO_NAMELOOKUP_TIME - Time spent in name resolution
CURLINFO_CONNECT_TIME - the time it took to establish the connection
CURLINFO_PRETRANSFER_TIME - the time elapsed from establishing the connection until the transfer is ready
CURLINFO_STARTTRANSFER_TIME - the time elapsed from establishment of the connection to the start of the transfer
CURLINFO_REDIRECT_TIME - The amount of time a redirect takes before a transaction transfer begins
CURLINFO_SIZE_UPLOAD - Total amount of data to upload
CURLINFO_SIZE_DOWNLOAD - Total amount of downloaded data
CURLINFO_SPEED_DOWNLOAD - average download speed
CURLINFO_SPEED_UPLOAD - Average upload speed
CURLINFO_HEADER_SIZE - size of header section
CURLINFO_HEADER_OUT - the string to send the request
CURLINFO_REQUEST_SIZE - The size of the request in question in the HTTP request
CURLINFO_SSL_VERIFYRESULT - The result of an SSL certificate verification request returned by setting CURLOPT_SSL_VERIFYPEER
CURLINFO_CONTENT_LENGTH_DOWNLOAD - Download content length read from Content-Length: field
CURLINFO_CONTENT_LENGTH_UPLOAD - Description of upload content size
CURLINFO_CONTENT_TYPE - Content-Type: value of the downloaded content, NULL means the server did not send a valid Content-Type: header
If opt is set, its value is returned 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 | illustrate |
---|---|
5.1.3 | Introduce CURLINFO_HEADER_OUT . |
<?php// Create a cURL handle $ch = curl_init('http://www.yahoo.com/');// Execute curl_exec($ch);// Check whether an error occurs if(!curl_errno($ ch)){ $info = curl_getinfo($ch); echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url'];}// Close handlecurl_close($ch);?>