Sbosh Posted April 17, 2020 Share Posted April 17, 2020 Good day everyone. My name is Sbosh am i am still a newbie in PHP as i am still a newbie in the group. Can someone please explain to me why my computer won't display my ip address? I have the following code: <?php $ip_address = $_SERVER['REMOTE_ADDR']; echo $ip_address; ?> But the output is always some dots and a 1 like so: ::1 Quote Link to comment https://forums.phpfreaks.com/topic/310603-ip-address-not-displaying/ Share on other sites More sharing options...
requinix Posted April 17, 2020 Share Posted April 17, 2020 That is an IP address. It's called IPv6. Quote Link to comment https://forums.phpfreaks.com/topic/310603-ip-address-not-displaying/#findComment-1576963 Share on other sites More sharing options...
TrueMember Posted April 17, 2020 Share Posted April 17, 2020 ::1 is the IP address of the client. Maybe what you want is: $_SERVER['SERVER_ADDR'] Quote Link to comment https://forums.phpfreaks.com/topic/310603-ip-address-not-displaying/#findComment-1576968 Share on other sites More sharing options...
Sbosh Posted April 17, 2020 Author Share Posted April 17, 2020 Hi True Member. The outcome is still the same though. I have a feeling it's not the code itself, but something to do with my computer. Quote Link to comment https://forums.phpfreaks.com/topic/310603-ip-address-not-displaying/#findComment-1576973 Share on other sites More sharing options...
Sbosh Posted April 17, 2020 Author Share Posted April 17, 2020 Hi requinix. Ok so in order for it to display in the form of 127.0.0.etc.. what do i need to do? Quote Link to comment https://forums.phpfreaks.com/topic/310603-ip-address-not-displaying/#findComment-1576974 Share on other sites More sharing options...
chhorn Posted April 17, 2020 Share Posted April 17, 2020 if ::1 then echo 127.0.0.1 Quote Link to comment https://forums.phpfreaks.com/topic/310603-ip-address-not-displaying/#findComment-1576976 Share on other sites More sharing options...
Phi11W Posted April 17, 2020 Share Posted April 17, 2020 3 hours ago, Sbosh said: in order for it to display in the form of 127.0.0.etc.. what do i need to do? Why do you feel the need to? IPv6 is already here and gaining in usage. Let's face it, there are only so many IPv4 Addresses and more devices coming on line every day. There will come a time when IPv4 will be is phased out. Why would you want to deliberately future-fail your code by locking it into this older protocol? There is no effective difference between "127.0.0.1" and "::1". It's the [loopback] address of the local machine and, once your Application goes out onto its real server, your Application will, most likely, never see it again, anyway. No real difference? Well, some of us might have to go buy a new T-Shirt to replace the one with this message: Quote There's no place like 127.0.0.1 ... 😉 Regards, Phill W. Quote Link to comment https://forums.phpfreaks.com/topic/310603-ip-address-not-displaying/#findComment-1576981 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.