mar*_*ark 19
在1.x使用
RequestHandlerComponent::getClientIP()
Run Code Online (Sandbox Code Playgroud)
它已经涵盖了您可能面临的所有问题
是的,"在您需要它的时间点"
对于2.x,最好使用
$this->request->getClientIp()
Run Code Online (Sandbox Code Playgroud)
从http://book.cakephp.org/2.0/en/appendices/2-0-migration-guide.html#requesthandlercomponent中记录的控制器内部