Performing DNS Lookups : DNS Functions « DNS « PHP






Performing DNS Lookups

 
gethostbyname() gets IP address corresponding to the hostname 
gethostbynamel() gets list of IP addresses corresponding to the hostname 
gethostbyaddr() gets hostname corresponding to an IP address 
getmxrr() fetches the mail exchange (MX) record associated with a hostname 
dns_get_mx() alias for getmxrr() 
checkdnsrr() checks for the existence of DNS records for a hostname 
dns_check_record() alias for checkdnsrr() 
dns_get_record() fetches DNS records associated with a hostname 

<?php
$ip = gethostbyname ( "www.java2s.com" );
echo "IP = $ip\n";
$host = gethostbyaddr ( "192.0.34.166" );
echo "Host = $host\n";
$ip = gethostbynamel ( "yahoo.com" );
print_r ( $ip );
?>
  
  








Related examples in the same category

1.DNS Lookup Functions
2.DNS Record Types and Their Meanings
3.Using the dns_check_record() Function
4.Fetches DNS records associated with a hostname