Skip to content

Instantly share code, notes, and snippets.

@unusorin
Created September 19, 2012 12:06
Show Gist options
  • Save unusorin/3749305 to your computer and use it in GitHub Desktop.
Save unusorin/3749305 to your computer and use it in GitHub Desktop.
domain available php
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment