The content of this article is about PHP getting the real IP of the visitor. Now I share it with everyone. Friends in need can take a look
/** * 获取来访者的真实IP * */ function getRealIp() { static $realip = null; if($realip !== null) { return $realip; } if(getenv('REMOTE_ADDR')) { $realip = getenv('REMOTE_ADDR'); } else if(getenv('HTTP_CLIENT_IP')) { $realip = getenv('HTTP_CLIENT_IP'); } else if (getenv('HTTP_X_FROWARD_FOR')) { $realip = getenv('HTTP_X_FROWARD_FOR'); } return $realip; }
Related recommendations:
003 - CI in your Using CodeIgniter resources in the class library
The above is the detailed content of 005-PHP gets the visitor's real IP. For more information, please follow other related articles on the PHP Chinese website!