php 获取客户端ip

php 获取客户端ip
 1 function getRealIp() {
 2         if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
 3            $ip = getenv("HTTP_CLIENT_IP");
 4         else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
 5            $ip = getenv("HTTP_X_FORWARDED_FOR");
 6         else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
 7            $ip = getenv("REMOTE_ADDR");
 8         else if (isset($_SERVER[‘REMOTE_ADDR‘]) && $_SERVER[‘REMOTE_ADDR‘] && strcasecmp($_SERVER[‘REMOTE_ADDR‘], "unknown"))
 9            $ip = $_SERVER[‘REMOTE_ADDR‘];
10         else
11            $ip = "unknown";
12         return($ip);
13     }
View Code

 

php 获取客户端ip,布布扣,bubuko.com

php 获取客户端ip

上一篇:sqlserver 表记录数统计


下一篇:通用的日志记录器(PHP)