PHP script to check server status online/offline

i wrote a simple php script to check whether the website or Ip address is online or offline. All you have to do is specify a website url or ip address and the script will return with ONLINE or OFFLINE. I used php fsockopen() to accomplish this.

/* Usage: 
$status =  GetServerStatus('http://domain.com',80)
or
$status =  GetServerStatus('IPAddress',80)
*/

<?php
function GetServerStatus($site, $port)
{
$status = array("OFFLINE", "ONLINE");
$fp = @fsockopen($site, $port, $errno, $errstr, 2);
if (!$fp) {
    return $status&#91;0&#93;;
} else 
  { return $status&#91;1&#93;;}
}
?>

If you want to ping a server to check connectivity, you can use php ping scripts.