PHP: verificare se un sito è online

Possiamo usare PHP per verificare se un sito è online o meno.

La soluzione è la seguente:


function is_website_online($host) {
    $port = 80;
    $timeout = 3;
    $fsock = fsockopen($host, $port, $errno, $errstr, $timeout);
    $status = (!$fsock) ? false : true; 
    return $status;   
}

Torna su