php 获取客户端ip

2020-11-15 03:52

阅读:682

标签:com   http   blog   style   class   div   img   code   log   tar   c   

bubuko.com,布布扣bubuko.com,布布扣
 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

标签:com   http   blog   style   class   div   img   code   log   tar   c   

原文地址:http://www.cnblogs.com/t-witness/p/3695940.html


评论


亲,登录后才可以留言!