php 获取客户端ip
2020-11-15 03:52
标签:com http blog style class div img code log tar c 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 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 }
下一篇:PHP源码分析