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

PHP 获取ip地址

2024/4/6 7:17:14发布16次查看
跳至
function getip() { static $ip = ''; $ip = $_server['remote_addr']; if(isset($_server['http_cdn_src_ip'])) { $ip = $_server['http_cdn_src_ip']; } elseif (isset($_server['http_client_ip']) && preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $_server['http_client_ip'])) { $ip = $_server['http_client_ip']; } elseif(isset($_server['http_x_forwarded_for']) and preg_match_all('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#s', $_server['http_x_forwarded_for'], $matches)) { foreach ($matches[0] as $xip) { if (!preg_match('#^(10|172\.16|192\.168)\.#', $xip)) { $ip = $xip; break; } } } return $ip; }
该用户其它信息

VIP推荐

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