# Web Development > PHP IP address

## timmy

I want to get ip address. How can I get it or what functions or methods can be used to get ip address using PHP

Timmy

----------


## norman

You can use REMOTE_ADDR or REMOTE_HOST   to achieve the above that is get ip address. But I want to know about super global variables in php. Someone throw highlight on this.

----------


## dhanasekaran07

$_SERVER variable are super global variable in php....

----------


## Niyati_1984

Remote_addr

----------


## baria mahesh

baria Mahesh::
you will use this code for getting ip address which is given below::

$ip = gethostbyname('www . example . com');
$out = "The following URLs are equivalent:\n";
$out .= '[[siteurl]], http://' . $ip . '/, and http://' . sprintf("%u", ip2long($ip)) . "/\n";
echo $out;
?>

ip2long() function given to you ip address or particular given hostname. 
 :Smile:

----------


## hemant pancholi

If you want the IP adreess than use gethostbyaddr() & if you want to url than use gethostbyname() function.

----------


## sm1590

u can use 

$ip=getHostByName(@"REMOT_ADDR");

i thinks its work...

----------


## manirgukt

It is better to use REMOTE_ADDR
*$ip = $_SERVER['REMOTE_ADDR'];*

----------


## johnpitter

If you want to fetch IP address using PHP than you have to use Given Code:

$ip=@$REMOTE_ADDR;
echo "*IP Address= $ip*";

Detecting the IP address is very important requirement for many scripts where we store the members or visitors details.

----------


## wbala4

For finding ip address make use of the website for free of cost.Also you can get the DNS query, hosting, and ping test information from the website.For normal PC(personal computer) IP address you can find by giving ping in the command prompt.

----------

