How do you check if a domain name exists?

BraveSirFoobar picture BraveSirFoobar · Jan 20, 2009 · Viewed 19.8k times · Source

Not only easy ones like .com or .net, but also, .co.uk, .fr, .gov.rw ... ?

Should I really make a huge mapping "tld to relevant whois server", or is there an easier way ?

Answer

Mike picture Mike · Dec 20, 2011

http://php.net/manual/en/function.checkdnsrr.php

if (checkdnsrr('test.nl', 'A')) // or use ANY or for other see above link
{
    echo 'Domain exists';
}
else
{
    echo 'Domain does not exist';
}