(PHP 4 >= 4.0.4, PHP 5)
curl_getinfo — Get information regarding a specific transfer
Gets information about the last transfer.
A cURL handle returned by curl_init().
This may be one of the following constants:
If opt is given, returns its value as a string. Otherwise, returns an associative array with the following elements (which correspond to opt):
Version | Description |
---|---|
5.1.3 | Introduced CURLINFO_HEADER_OUT. |
Example #1 curl_getinfo() example
<?php
// Create a curl handle
$ch = curl_init('http://www.yahoo.com/');
// Execute
curl_exec($ch);
// Check if any error occured
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);
?>
Note:
Information gathered by this function is kept if the handle is re-used. This means that unless a statistic is overridden internally by this function, the previous info is returned.