• 1.
    function checkOnline($domain) {
  • 2.
       $curlInit = curl_init($domain);
  • 3.
       curl_setopt($curlInit,CURLOPT_CONNECTTIMEOUT,10);
  • 4.
       curl_setopt($curlInit,CURLOPT_HEADER,true);
  • 5.
       curl_setopt($curlInit,CURLOPT_NOBODY,true);
  • 6.
       curl_setopt($curlInit,CURLOPT_RETURNTRANSFER,true);
  • 7.
     
  • 8.
       // Récupération de la réponse
  • 9.
       $response = curl_exec($curlInit);
  • 10.
     
  • 11.
       curl_close($curlInit);
  • 12.
       if ($response) return true;
  • 13.
       return false;
  • 14.
    }
  • 15.
     
  • 16.
    if(checkOnline('google.com')) echo "Online !";
  • 17.
    else echo "Offline !";
function checkOnline($domain) { $curlInit = curl_init($domain); curl_setopt($curlInit,CURLOPT_CONNECTTIMEOUT,10); curl_setopt($curlInit,CURLOPT_HEADER,true); curl_setopt($curlInit,CURLOPT_NOBODY,true); curl_setopt($curlInit,CURLOPT_RETURNTRANSFER,true); // Récupération de la réponse $response = curl_exec($curlInit); curl_close($curlInit); if ($response) return true; return false; } if(checkOnline('google.com')) echo "Online !"; else echo "Offline !";

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter