I\'m using CURL to get the status of a site, if it\'s up/down or redirecting to another site. I want to get it as streamlined as possible, but it\'s not working well.
<
function getStatusCode()
{
$url = 'example.com/test';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, true); // we want headers
curl_setopt($ch, CURLOPT_NOBODY, true); // we don't need body
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT,10);
$output = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return $httpcode;
}
print_r(getStatusCode());