刚刚通过php手册它说
'SERVER_ADDR' 正在执行当前脚本的服务器的 IP 地址。
'REMOTE_ADDR' 用户正在查看当前页面的 IP 地址。
对于像我这样对编程知之甚少的人来说,他们的意思是一样的,即获取 IP 地址。那么我应该使用哪个来简单地获取访问我网站的客户端的 IP 地址?
假设您有一个在服务器上运行的 php 程序(或脚本,您可以随意称呼它),并且您可以从您的家用计算机访问该脚本。然后,在这种情况下:
SERVER_ADDR is the IP address of the server on which the script is located and ran
REMOTE_ADDR is the IP address of the computer that sent the request (e.g your home computer)
Run Code Online (Sandbox Code Playgroud)