PHP Site Online Check

Site Online Check

<? 
$site = "codelibary.com";
$check = fsockopen($site, 80);

if ($check) {
    echo "$site is online";
}
else {
    echo "$site is offline";
}
?>