Home | Scripts | Tutorials | Books | Hosting | Forums | Links|

Navigation:

Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Blog
Books
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links






 
 

SPONSORS



 
 

DNS Functions

One of the wonderful things about PHP is the large amount of useful functions that it contains , here we will look at a couple of DNS functions . gethostbyaddr() and gethostbyname() . Unlike other languages you dont need a third party component in PHP .

gethostbyaddr() example

This example gets the Internet host name corresponding to a given IP address . We are getting the IP address of whoever is looking at the page .

<?php
$ip = gethostbyaddr($REMOTE_ADDR);
echo $ip;
?>

and here is the result

38.103.63.59

gethostbyname() example

With this function we get the IP address corresponding to a given Internet host name , in this example www.microsoft.com and get the ip address of it.

<?php
$ipaddress = gethostbyname("www.microsoft.com");
echo "$ipaddress";
?>

and here is the result

207.46.19.254