If you want to actually retrieve the file, use Frederick's way. If you just want to check the server, you can use either his or this one:
$fp = fsockopen('example.com', 80, $errno, $errstr, 20);
if ($fp) {
echo 'Server is up.';
} else {
echo 'Server is down';
}
Edit: forgot to close the connection:
fclose($fp);
should go right after 'Server is up'.