PHP curl_getinfo Function
(PHP 4 >= 4.0.4, PHP 5)
curl_getinfo — Get information about a cURL connection resource handle
Description
mixed curl_getinfo ( resource $ch [, int $opt = 0 ] )
Gets information about the last transfer.
Parameters
ch
A cURL handle returned by curl_init().
opt
This parameter may be one of the following constants:
- CURLINFO_EFFECTIVE_URL - The last effective URL
- CURLINFO_HTTP_CODE - The last received HTTP code
- CURLINFO_FILETIME - The time it took to fetch the remote document; if it could not be fetched, the value is "-1"
- CURLINFO_TOTAL_TIME - The time consumed by the last transfer
- CURLINFO_NAMELOOKUP_TIME - The time consumed by name resolution
- CURLINFO_CONNECT_TIME - The time consumed to establish the connection
- CURLINFO_PRETRANSFER_TIME - The time from connection establishment until the transfer is ready
- CURLINFO_STARTTRANSFER_TIME - The time from connection establishment until the transfer begins
- CURLINFO_REDIRECT_TIME - The time spent on redirection before the transaction transfer begins
- CURLINFO_SIZE_UPLOAD - The total amount of data uploaded
- CURLINFO_SIZE_DOWNLOAD - The total amount of data downloaded
- CURLINFO_SPEED_DOWNLOAD - The average download speed
- CURLINFO_SPEED_UPLOAD - The average upload speed
- CURLINFO_HEADER_SIZE - The size of the header section
- CURLINFO_HEADER_OUT - The string of the request sent
- CURLINFO_REQUEST_SIZE - The size of the request in question in the HTTP request
- CURLINFO_SSL_VERIFYRESULT - Set viaCURLOPT_SSL_VERIFYPEERThe result of the returned SSL certificate verification request
- CURLINFO_CONTENT_LENGTH_DOWNLOAD - FromContent-Length: the length of the downloaded content read from the field
- CURLINFO_CONTENT_LENGTH_UPLOAD - A description of the upload content size
- CURLINFO_CONTENT_TYPE - The downloaded content'sContent-Type:value; NULL means the server did not send a validContent-Type: header
Return Value
If opt is set, its value is returned as a string. Otherwise, an associative array containing the following elements (each corresponding to opt) is returned:
- "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"
Changelog
| Version | Description |
|---|---|
| 5.1.3 | Introduced in**CURLINFO_HEADER_OUT**. |
Example
PHP cURL Reference Manual