Return to Snippet

Revision: 27185
at May 26, 2010 23:53 by metoikos


Initial Code
<?
 
# Domain Name
$domainName = "http://www.symfony-projects.org" ;
 
# Function
function DomainCheck($domainName){
    $startTime = microtime(true);
    $openDomain = fsockopen ($domainName, 80, $errno, $errstr, 10);
    $finishTime  = microtime(true);
    $serverStatus    = 0;
    # Control Structure
    if (!$openDomain) $serverStatus = -1;  
    else {
        fclose($openDomain);
        $status = ($finishTime - $startTime) * 1000;
        $serverStatus = floor($serverStatus);
    }
    return $serverStatus;
}
 
# Server Status
$serverStatus = DomainCheck($domainName);
 
# Result
if ($serverStatus != -1) {
echo "Server is OFF right now" ;
} else {
echo "Server is ON; everyhing is OK." ;
} 
 
?>

Initial URL

                                

Initial Description

                                

Initial Title
php server status check

Initial Tags
php, server

Initial Language
PHP