Obtener código HTTP

<?php
function get_link_header($aUrl) {
if (preg_match("/^http:\/\//",$aUrl)) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $aUrl);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_exec($ch);
$info = curl_getinfo($ch);
curl_close ($ch);
if (!empty($info)) {
return $info['http_code'];
} else {
return 0;
}
} else {
return 0;
}
}