What is the difference between 'REMOTE_ADDR' and 


What is the difference between 'REMOTE_ADDR' and 'SERVER_ADDR' in php?

刚刚浏览了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)