您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php获取用户真实 IP

2024/6/2 23:11:35发布62次查看
​/** * 获取用户真实 ip */function getip(){ static $realip; if (isset($_server)){ if (isset($_server[http_x_forwarded_for])){ $realip = $_server[http_x_forwarded_for]; } else if (isset($_server[http_client_ip])) { $realip = $_server[http_client_ip]; } else { $realip = $_server[remote_addr]; } } else { if (getenv(http_x_forwarded_for)){ $realip = getenv(http_x_forwarded_for); } else if (getenv(http_client_ip)) { $realip = getenv(http_client_ip); } else { $realip = getenv(remote_addr); } } return $realip;}/** * 获取 ip 地理位置 * 淘宝ip接口 * @return: array */function getcity($ip){ $url=http://ip.taobao.com/service/getipinfo.php?ip=.$ip; $ip=json_decode(file_get_contents($url)); if((string)$ip->code=='1'){ return false; } $data = (array)$ip->data; return $data; }
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product