check if a site id sown

This will use the fsockopen function to try and connect to a site,

<?php
$site = fsockopen('www.google.com', 80);
// check if the website is found
if(!$site)
{
echo'Site down';
}
else
{
echo'Site is online';
}

?>