1$url = 'http://www.example.com';
2$ch = curl_init($url);
3curl_setopt($ch, CURLOPT_HEADER, true); // we want headers
4curl_setopt($ch, CURLOPT_NOBODY, true); // we don't need body
5curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
6curl_setopt($ch, CURLOPT_TIMEOUT,10);
7$output = curl_exec($ch);
8$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
9curl_close($ch);
10
11echo 'HTTP code: ' . $httpcode;