这两个变量之间的区别是什么?
REMOTE_HOST和REMOTE_ADDR。
发布于 2010-09-28 19:28:42
REMOTE_HOST与客户端(即发出请求的计算机)的主机名有关。REMOTE_ADDR是指客户端的IP地址。
有时主机名无法解析,因此REMOTE_HOST将返回REMOTE_ADDR或IP地址。
发布于 2016-12-29 23:21:45
1. $_SERVER['REMOTE_ADDR'] -它包含客户端的真实IP地址。这是您能从用户那里找到的最可靠的值。
2. $_SERVER['REMOTE_HOST'] -这将获取用户查看当前页面的主机名。但要使此脚本正常工作,必须在httpd.conf内部配置主机名查找。
发布于 2019-09-04 17:19:44
来自RFC-3875:
REMOTE_ADDR = hostnumber
hostnumber = ipv4-address | ipv6-address
ipv4-address = 1*3digit "." 1*3digit "." 1*3digit "." 1*3digit
ipv6-address = hexpart [ ":" ipv4-address ]
hexpart = hexseq | ( [ hexseq ] "::" [ hexseq ] )
hexseq = 1*4hex *( ":" 1*4hex )The REMOTE_HOST variable contains the fully qualified domain name of
the client sending the request to the server, if available, otherwise
NULL. Fully qualified domain names take the form as described in
section 3.5 of RFC 1034 [17] and section 2.1 of RFC 1123 [12].
Domain names are not case sensitive.
REMOTE_HOST = "" | hostname | hostnumber
hostname = *( domainlabel "." ) toplabel [ "." ]
domainlabel = alphanum [ *alphahypdigit alphanum ]
toplabel = alpha [ *alphahypdigit alphanum ]
alphahypdigit = alphanum | "-"https://stackoverflow.com/questions/3812166
复制相似问题