PHP curl_getinfo function
PHP curl_getinfo function
(PHP 4> = 4.0.4, PHP 5)
curl_getinfo - Get information about a connection resource handle cURL
Explanation
mixed curl_getinfo ( resource $ch [, int $opt = 0 ] )
Get last transfer of information.
parameter
ch
By the curl_init () returns a cURL handle.
opt
This parameter may be one of the following constants:
- CURLINFO_EFFECTIVE_URL - the last valid URL address
- CURLINFO_HTTP_CODE - last received HTTP code
- CURLINFO_FILETIME - remote acquisition of documentation time, if you can not get the return value is "-1"
- CURLINFO_TOTAL_TIME - last transfer time consumed
- CURLINFO_NAMELOOKUP_TIME - name resolution time consumed
- CURLINFO_CONNECT_TIME - the amount of time to establish a connection
- CURLINFO_PRETRANSFER_TIME - From time to establish a connection to the transmission ready for use
- CURLINFO_STARTTRANSFER_TIME - transmission start time is used to establish a connection from
- Time before the beginning of the transmission transaction redirection used - CURLINFO_REDIRECT_TIME
- CURLINFO_SIZE_UPLOAD - Gross amount of data uploaded
- CURLINFO_SIZE_DOWNLOAD - the total value of the amount of data downloaded
- CURLINFO_SPEED_DOWNLOAD - Average download speed
- CURLINFO_SPEED_UPLOAD - Average upload speed
- The size of the header section - CURLINFO_HEADER_SIZE
- CURLINFO_HEADER_OUT - sent the request string
- The size of a problem in the HTTP request requests - CURLINFO_REQUEST_SIZE
- CURLINFO_SSL_VERIFYRESULT - Results by setting the SSL certificate verification request returned CURLOPT_SSL_VERIFYPEER
- CURLINFO_CONTENT_LENGTH_DOWNLOAD - from Content-Length: download read length field in
- CURLINFO_CONTENT_LENGTH_UPLOAD - upload size Description
- CURLINFO_CONTENT_TYPE - download the Content-Type: value, NULL indicates server did not send valid Content-Type: header
return value
If opt is set to a string and returns its value. Otherwise, Return an associative array with the following elements (which 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"
Update Log
version | Explanation |
---|---|
5.1.3 | Introduced CURLINFO_HEADER_OUT . |
Examples
<?php // 创建一个cURL句柄 $ch = curl_init('http://www.yahoo.com/'); // 执行 curl_exec($ch); // 检查是否有错误发生 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); ?>