Posted By

wireplay on 09/03/10


Tagged

php ip-address


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

fwd
kairog
roli000
moondreamer


PHP - Get Real IP Address


 / Published in: PHP
 

  1. <?php
  2. function getRealIpAddr()
  3. {
  4. if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
  5. $ip=$_SERVER['HTTP_CLIENT_IP'];
  6. } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  7. $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
  8. } else {
  9. $ip=$_SERVER['REMOTE_ADDR'];
  10. }
  11. return $ip;
  12. }
  13. $useripaddress = getRealIpAddr();
  14.  
  15. echo $useripaddress;
  16. ?>

Report this snippet  

You need to login to post a comment.