如何在PHP(CLI)中找到服务器的IP地址 [英] How do I find my server's IP address in PHP(CLI)
本文介绍了如何在PHP(CLI)中找到服务器的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
除了显而易见的(localhost,127.0.0.1)之外,PHP(命令行界面!)是否具有一种机制来发现脚本在其上运行的计算机的IP?
Aside from the obvious (localhost, 127.0.0.1) does PHP (command line interface!) have a mechanism for discovering the IP of the computer the script is running on?
$_SERVER[*]
将不起作用,因为这不是Web应用程序-这是命令行脚本.
$_SERVER[*]
will not work as this is not a Web app - this is a command line script.
TIA
推荐答案
您可以使用 gethostname
You can get the hostname by using gethostname
这篇关于如何在PHP(CLI)中找到服务器的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文