<?php
function getHTTPInfo($url, $followLocation = false)
{
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_MAXREDIRS, 5);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, $followLocation);
curl_exec($curl);
$httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$effectiveURL = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
curl_close($curl);
return array('http_code' => $httpStatus,
'effective_url' => $effectiveURL);
}
$result = getHTTPInfo('http://plantpath.unl.edu/', true);
var_dump($result);
preferences:
37.64 ms | 402 KiB | 5 Q