Using PHP to Check a Domain or URL

Just like to jot a quick line when I find a good function or class. This is about the best PHP code I’ve come across to test a URL and see if a Website is available. ┬áThe source is from the CSS Tricks site but I found it on CatsWhoCode.

<?php
 
       if (isDomainAvailible('http://www.css-tricks.com'))
       {
               echo "Up and running!";
       }
       else
       {
               echo "Woops, nothing found there.";
       }
 
       //returns true, if domain is availible, false if not
       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;
 
               return false;
       }
?>