PHP: inconsistent results for gethostbyname() and checkdnsrr() -


i'm writing simple form check if .com domain available. i'm evaluating 3 methods (@dns_get_record, gethostbyname() , checkdnsrr()) bunch of test domain names below code, getting not available entries gethostbyname() , checkdnsrr(), can see @ http://suggestmyname.com/nonwp/arraypush.php if refresh few times. don't issue when running on local testing server, know why inconsistency? not of domains being checked on remote server, on local testing server.

$sdomains = array(); array_push($sdomains, 'etc.com');  function domainavailable1($domain){ $results = @dns_get_record($domain, dns_any); return empty($results); } function domainavailable2($domain){ return gethostbyname($domain) == $domain; } function domainavailable3($domain){ return !checkdnsrr($domain, 'any'); }  echo '<table><tr><td>@dns_get_record</td><td>gethostbyname</td><td>checkdnsrr</td></tr>';         foreach($sdomains $sdomain){ if (domainavailable1($sdomain) == true){                                 echo '<tr><td bgcolor=green>' . $sdomain . ' available!</td>';             } else {             echo '<tr><td bgcolor=red>' . $sdomain . ' not available.</td>';             } if (domainavailable2($sdomain) == true){                                 echo '<td bgcolor=green>' . $sdomain . ' available!</td>';             } else {             echo '<td bgcolor=red>' . $sdomain . ' not available.</td>';             } if (domainavailable3($sdomain) == true){                                 echo '<td bgcolor=green>' . $sdomain . ' available!</td></tr>';             } else {             echo '<td bgcolor=red>' . $sdomain . ' not available.</td></tr>';             } } 

i'm not sure using of functions (basically using dns in general) reliable method determine if domain available.

i have plenty of domains registered have absolutely no dns records can't resolved means, domains of course taken.

while domains have dns records, there cases there aren't any. example domain mymoney.com in script says available through 3 checks, domain registered.

your best bet use whois query appropriate registrar given tld , use whois determine availability. think if try use dns, there false positives or other problems run into.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -