/** * 获取服务器的ip * @access public * @return string **/ function real_server_ip(){ static $serverip = NULL; if ($serverip !== NULL){ return $serverip; } if (isset($_SERVER)){ if (isset($_SERVER['SERVER_ADDR'])){ $serverip = $_SERVER['SERVER_ADDR']; } else{ $serverip = '0.0.0.0'; } } else{ $serverip = getenv('SERVER_ADDR'); } return $serverip; }
|