Zend - The PHP Company




Miscellaneous

Add Code


Domain checker  

Type: code fragment
Added by: stiawan
Entered: 02/05/2002
Last modified: 05/12/2001
Rating: - (fewer than 3 votes)
Views: 5103
Function to check is a domain available or not?


<?php
function lookup($domain)
{
    
exec("host -t ns $domain",$hasil);
    if (
ereg("host not found.",strtolower(trim($hasil[0])))) // Mungkin cuma 1 ns atau tidak ditemukan
    
{
        return 
false;
    } else
    {
        
$hasilstr="";
        for (
$i=0;$i<=count($hasil);$i++)
        {
            
$hasilstr.=ereg_replace("$domain name server","<LI>",$hasil[$i])."<BR>";
        }
        return 
$hasilstr;
    }
}

?>


Usage Example


<?
   $domain
="stiawan.net";
   if (!
lookup($domain))
   {
      echo 
"Availabe";
   } else
   {
      echo 
"Not available";
   }
?>


Rate This Script





Search



This Category All Categories