Posted By

irishsk on 11/11/08


Tagged


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

sidisinsane
vali29
jpsirois
jlvallelonga


Get IP address


 / Published in: PHP
 

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

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

Report this snippet  

You need to login to post a comment.