Home > Backend Development > PHP Tutorial > PHP code to get user IP address

PHP code to get user IP address

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-25 08:42:51
Original
877 people have browsed it
  1. function getRealIpAddr()
  2. {
  3. if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
  4. {
  5. $ip=$_SERVER['HTTP_CLIENT_IP'];
  6. }
  7. elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
  8. {
  9. $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
  10. }
  11. else
  12. {
  13. $ip=$_SERVER['REMOTE_ADDR'];
  14. }
  15. return $ip;
  16. }
复制代码

PHP


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template