1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Detect a User's IP Address

How to detect a user's IP address using PHP code


An IP address can tell you a lot about a user, such as the general area from which they are visiting your site. This can help you specialize the site's content for your users, or redirect them based on location. You can also use a person's IP address as a security measure to make sure it is actually them logging into their account. You could also use it to check your own IP address to know if a proxy server is working.

 echo "Your IP Address is $ip"; 

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

Related Video
Link a Website to an Email Address in HTML
  1. About.com
  2. Technology
  3. PHP / MySQL
  4. Learn PHP
  5. How to Detect a User's IP Address Using PHP Code

©2014 About.com. All rights reserved.