title: PHP: Check if a website is online
body: <p>I have a curl based function in php to check if a website is online that works fine however i have noticed that it only works for http links and not https links.</p>
  
  <p>Does anyone know how this function can be updated to support https links also.</p>
  
  <pre><code>function isDomainAvailible($domain){
      // Check, if a valid url is provided
      if(!filter_var($domain, FILTER_VALIDATE_URL)){
          return false;
      }
  
      // Initialize curl
      $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);
  
      // Get answer
      $response = curl_exec($curlInit);
  
      curl_close($curlInit);
  
      if ($response){ 
          return true;
      } else { 
          return false;
      }
  }
  </code></pre>