Domain Availability

Jan 17, 2012 Asset Management


A few client’s were looking to expand their internet empire, hoping to automate a process to check domain availability. I put together the below script which would do just that for them. It uses the whois servers from, and makes a simple cURL GET request. The response is then parsed for the text, “appears to be available”, and the response is returned. Use as you see fit. The below is now being released under GPLv2. It is a quick, but not fool-proof way of using out-of-date whois servers.

The Code

function domainAvailability($domain, $tld){ 
    $ch = curl_init("$domain.$tld/");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    $output = curl_exec($ch); curl_close($ch);
    if(strstr($output, 'appears to be available')){ 
        return true; 

    return false; 

echo "Checking ". 

(domainAvailability('highonphp', 'com') ? 'Available' : 'Taken')."\n"; echo "Checking ". 

(domainAvailability('highonphp', 'net') ? 'Available' : 'Taken')."\n";


The above code does the following:

_ Disclaimer: has spam prevention detection enabled on their site. We are not affiliated with and do not encourage abuse of the above script._

comments powered by Disqus