Posted By

iTony on 06/20/09


Tagged

php ip


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

Nanobyte
wizard04
batamire
vali29


Get IP


 / Published in: PHP
 

  1. function getRealIpAddr(){
  2. if (!empty($_SERVER['HTTP_CLIENT_IP'])) { //check ip from share internet
  3. $ip=$_SERVER['HTTP_CLIENT_IP'];
  4. } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //to check ip is pass from proxy
  5. $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
  6. } else {
  7. $ip=$_SERVER['REMOTE_ADDR'];
  8. }
  9. return $ip;
  10. }

Report this snippet  

You need to login to post a comment.