PHP - Get Real IP Address


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.