PHP Howto Read IP address of remote computer/browser
PHP has in built facility to detect remote browser or IP address and other properties. These values are assigned to special variable. In this case, it is assigned to variable called REMOTE_ADDR. You can use any one of the following statement to obtained or read IP address:
$ip = $_SERVER['REMOTE_ADDR'];
OR
$ip= $REMOTE_ADDR;
Here is sample code:
<?
$ip= $REMOTE_ADDR;
echo "<br> Your IP address : " . $ip;
echo "<br> Your hostname : " . GetHostByName($ip);
?>
See PHP getenv for more information.
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- PostgreSQL psql: could not connect to server: Connection refused
- How to determine or retrieve visitor’s IP address using PHP
- Linux change ip address
- Openbsd list open tcp or udp ports
- Ping IPv6 IP Address With ping6 Command
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!


October 2nd, 2007 at 3:49 pm
hi,
I am trying to figure out the “spam” word enabled form submission like this one …anyone here can help me ..
Thanks
November 28th, 2007 at 3:30 pm
You can get the host name from IP.gethostbyname
Try the gethostbyaddr for this task.
January 2nd, 2008 at 1:23 pm
How to get the remote IP location?
January 4th, 2008 at 5:42 pm
<?php
$ip = $_SERVER['REMOTE_ADDR'];
And if you want to echo it use
that is what i use
January 6th, 2008 at 2:09 am
hey! this is a child’s play! such an easy thing! i said that coz i am 15 and a hard core PHP developer!!