Check if a domain is Registered with PHP


Today I would like to share a very simple PHP code snippet that lets you know if a given specific domain is registered or available for purchase or not.To check if a domain is registered or not we will use the PHP’s built in function called checkdnsrr().This function searches for the DNS records of the given domain and if they are not available that means the domain is not registered and it is available.

Here is a simple script that you can use:


function is_domain_available ( $domain ) {

return checkdnsrr ( $domain , 'ANY' ) ? $domain . ' is already registered' : $domain . ' is available' ;


// how to use :

$domain = '' ;

echo is_domain_available ( $domain ) ;


Output is is already registered. just you need to pass the domain name to the function.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.