标签:
function getIp() { static $realip = NULL; if ($realip !== NULL) { return $realip; } if (getenv( ‘HTTP_X_FORWARDED_FOR‘)) { $realip = getenv( ‘HTTP_X_FORWARDED_FOR‘); } elseif (getenv( ‘HTTP_CLIENT_IP‘)) { $realip = getenv( ‘HTTP_CLIENT_IP‘); } else { $realip = getenv( ‘REMOTE_ADDR‘); } preg_match("/[\d\.]{7,15}/", $realip, $onlineip); $realip = !empty($onlineip[0]) ? $onlineip[0] : ‘0.0.0.0‘; return $realip; }
标签:
原文地址:http://www.cnblogs.com/beijingwuyanzu/p/5946638.html