Код:
<?php
function query($url, $info = false) {
if($info) { global $info; $info = array(); }
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$content = curl_exec($ch);
if(is_array($info)) {
$info = curl_getinfo($ch);
}
curl_close($ch);
return $content;
}
$content = query('http://yandex.ru', true);
var_dump($info);
?>
вывод:
array
'url' => string 'http://www.yandex.ru/' (length=21)
'content_type' => string 'text/html; charset=windows-1251' (length=31)
'http_code' => int 200
'header_size' => int 737
'request_size' => int 100
'filetime' => int -1
'ssl_verify_result' => int 0
'redirect_count' => int 1
'total_time' => float 0.072896 // время на всю операцию
'namelookup_time' => float 0.003366
'connect_time' => float 0.005547 // время получения ответа ( то , что было нужно )
'pretransfer_time' => float 0.00555
'size_upload' => float 0
'size_download' => float 30828
'speed_download' => float 422903
'speed_upload' => float 0
'download_content_length' => float 30828
'upload_content_length' => float 0
'starttransfer_time' => float 0.044669
'redirect_time' => float 0.012824