1. Computing

Discuss in my forum

What Is My IP?

By , About.com Guide

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!

Related Video
Basic PHP Syntax
Using PHP With HTML
  1. About.com
  2. Computing
  3. PHP / MySQL
  4. Learn PHP
  5. What is my IP - PHP IP Finding Script - PHP User IP Lookup

©2013 About.com. All rights reserved.