1. Home
  2. Computing & Technology
  3. PHP / MySQL

What Is My IP?

By Angela Bradley, About.com

Show your user's their IP address:

Retrieving the user's IP address is actually much simpler than you might think, and can be done in a single line. Getenv("REMOTE_ADDR") will return the IP address of the person visiting your site. Generally this is accurate, however if the user is running through a proxie server, then it will return the address of the proxie.

In this example, we retrieve the user's IP and then simply echo it's value back to the user.

<?php
//Gets the IP address
$ip = getenv("REMOTE_ADDR") ;
Echo "Your IP is " . $ip;
?>

Have something to add? A bit of code? A suggestion of how to use it? View Reader Responses!

Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Learn PHP
  5. What is my IP - PHP IP Finding Script - PHP User IP Lookup

©2009 About.com, a part of The New York Times Company.

All rights reserved.