Posted By

luman on 01/24/09


Tagged

ip


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

jeremyhcobb
umang_nine
dsntos
vali29


Function to find real IP address in PHP


 / Published in: PHP
 

URL: http://roshanbh.com.np/2007/12/getting-real-ip-address-in-php.html

  1. <?php
  2. function getRealIpAddr()
  3. {
  4. if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
  5. {
  6. $ip=$_SERVER['HTTP_CLIENT_IP'];
  7. }
  8. elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
  9. {
  10. $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
  11. }
  12. else
  13. {
  14. $ip=$_SERVER['REMOTE_ADDR'];
  15. }
  16. return $ip;
  17. }
  18. ?>

Report this snippet  

You need to login to post a comment.