remote_addr 不返回 IPv4 地址

2022-01-14 00:00:00 ip-address xampp php

我在本地主机上使用 xampp,当我使用 $_SERVER["REMOTE_ADDR"] 它返回 ::1 (也在 phpinfo()).为什么这样做?我希望它返回一个正常的 IP 地址,如 127.0.0.1.我的操作系统是 windows vista.

I am using xampp on localhost and when I use $_SERVER["REMOTE_ADDR"] it returns ::1 (also does this in phpinfo()). Why does it do this? I want it to return a normal ip address like 127.0.0.1. My operating system is windows vista.

推荐答案

::1 是一个 IPv6 地址 和 0:0:0:0:0:0:0:1 的缩写,即 环回地址到本地机器.所以 ::1127.0.0.1 相同,只是通过 IPv6 而不是 IPv4.

::1 is an IPv6 address and an abbreviation for 0:0:0:0:0:0:0:1 that is the loopback address to the local machine. So ::1 is the same as 127.0.0.1 only via IPv6 instead of IPv4.

相关文章