PHP Get User’s IP Address

Getting the user's IP address is extremely easy to do in PHP. Here is a snippet that I use, which includes a bit of grooming. Remember, never trust any input...

$ip = ereg_replace('([^[:digit:]\.])','',$_SERVER['REMOTE_ADDR']);

  • Digg
  • TwitThis
  • del.icio.us
  • Netvouz
  • description
  • Reddit
  • Furl
  • NewsVine
  • Simpy
  • Slashdot
  • Spurl
  • StumbleUpon
  • YahooMyWeb
  • TailRank
  • Technorati
  • Facebook
  • Google
  • LinkedIn
  • Live
  • MySpace
  • Ping.fm
  • Yahoo! Buzz
  • E-mail this story to a friend!



Home | PHP | PHP Get User’s IP Address