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

PHP获取用户IP地址的方法

2024/3/30 0:00:30发布5次查看
本篇文章介绍的是关于php获取用户ip地址的方法,现在分享给大家,也给需要有帮助的朋友一个参考,大家一起来看一看吧
/** * 用来获取用户的ip地址方法 * @return array|false|string 用户的ip地址 */ public function getuserip() { if(getenv("http_client_ip") && strcasecmp(getenv("http_client_ip"), "unknow")){ $ip = getenv("http_client_ip"); }else if(getenv("http_x_forwarded_for") && strcasecmp(getenv("http_x_forwarded_for"), "unknow")){ $ip = getenv("http_x_forwarded_for"); }else if(getenv("remote_addr") && strcasecmp(getenv("remote_addr"), "unknow")){ $ip = getenv("remote_addr"); }else if(isset($_server["remote_addr"]) && $_server["remote_addr"] && strcasecmp($_server["remote_addr"],"unknow")){ $ip = $_server["remote_addr"]; }else{ $ip = "unknow"; } return $ip; }
相关推荐:
php获取文件大小详解
php获取当前域名的方法
php获取开始时间和结束时间的方法
以上就是php获取用户ip地址的方法的详细内容。
该用户其它信息

VIP推荐

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