PHP中机器的IP地址为:: 1,但是为什么呢? [英] IP Address of the machine in PHP gives ::1 but why?

查看:105
本文介绍了PHP中机器的IP地址为:: 1,但是为什么呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过php获取我的计算机的IP地址.为此,我正在编写如下代码:

I am trying to fetch the ip address of my machine through php. For that I am writing the code like:

<?php echo  "<br />".$_SERVER['REMOTE_ADDR'];?>

但是这段代码不起作用.它返回"::1". 请帮助我如何获取实际的IP地址.

But this piece of code is not working. It is returning "::1". Please help me how to get the actual IP Address.

推荐答案

::1是实际IP.这是一个ipv6环回地址(即localhost).如果您使用的是ipv4,则为127.0.0.1.

::1 is the actual IP. It is an ipv6 loopback address (i.e. localhost). If you were using ipv4 it would be 127.0.0.1.

如果要获取其他IP地址,则需要通过其他网络接口连接到服务器.

If you want to get a different IP address, then you'll need to connect to the server through a different network interface.

这篇关于PHP中机器的IP地址为:: 1,但是为什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆