问题描述
此程序仅在本地主机中返回客户端计算机名称
This program only returns the client machine name in localhost only
echo gethostbyaddr($_SERVER['REMOTE_ADDR']);
如果它是从联机服务器运行的,则不会显示计算机名称,而是会显示一些其他信息.因此,当程序从在线服务器运行时,是否有任何方法可以在php中获取计算机名称.
If it is run from an online server, then computer name is not shown and some other information is being shown.So is there anyway to get the computer name in php when the program runs from online server.
推荐答案
其他信息"是什么? IP地址?
What's this "other information"? An IP address?
在PHP中,您使用$_SERVER['REMOTE_ADDR']
获取远程客户端的IP地址,然后可以使用 gethostbyaddr()
尝试将该IP转换为主机名-但并非所有IP都配置了反向映射.
In PHP, you use $_SERVER['REMOTE_ADDR']
to get the IP address of the remote client, then you can use gethostbyaddr()
to try and conver that IP into a hostname - but not all IPs have a reverse mapping configured.
这篇关于在PHP中获取客户端计算机名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!