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

php 获取客户端ip

2024/5/10 10:34:07发布20次查看
无详细内容 无 /** * 获取客户端ip地址 * @param integer $type 返回类型 0 返回ip地址 1 返回ipv4地址数字 * @return mixed */function get_client_ip($type = 0) {$type = $type ? 1 : 0; static $ip = null; if ($ip !== null) return $ip[$type]; if (iss
/** * 获取客户端ip地址 * @param integer $type 返回类型 0 返回ip地址 1 返回ipv4地址数字 * @return mixed */function get_client_ip($type = 0) { $type = $type ? 1 : 0; static $ip = null; if ($ip !== null) return $ip[$type]; if (isset($_server['http_x_forwarded_for'])) { $arr = explode(',', $_server['http_x_forwarded_for']); $pos = array_search('unknown',$arr); if(false !== $pos) unset($arr[$pos]); $ip = trim($arr[0]); }elseif (isset($_server['http_client_ip'])) { $ip = $_server['http_client_ip']; }elseif (isset($_server['remote_addr'])) { $ip = $_server['remote_addr']; } // ip地址合法验证 $long = sprintf(%u,ip2long($ip)); $ip = $long ? array($ip, $long) : array('0.0.0.0', 0); return $ip[$type];}
该用户其它信息

VIP推荐

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