如何在PHP Web服务中获取客户端的IP地址? [英] How can I get the client's IP address in a PHP webservice?

查看:278
本文介绍了如何在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.

http://php.net/manual/en/reserved.variables. server.php

这篇关于如何在PHP Web服务中获取客户端的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆