如何在PHP Web服务中获取客户端的IP地址?
问题描述:
我已经开发了一个PHP Web服务.我想记录使用此Web服务的WS客户端的所有传入连接.如何获得客户的IP地址?
I have developed a PHP webservice. I would like to log all incoming connections of the WS clients, which are consuming this web service. How can I obtain the client's IP address? The value of
$_SERVER['HTTP_CLIENT_IP']
的值 似乎总是空的.
答
这应该是您想要的:
$_SERVER['REMOTE_ADDR']
用户所在的IP地址 查看当前页面.
The IP address from which the user is viewing the current page.