2

I already use xampp 3.2.1 version and $_SERVER['SERVER_ADDR'] was fine. It returned some thing like this 172.0.0.1. But now I have updated my Xampp to 5.6.3 version and now $_SERVER['SERVER_ADDR'] doesn't work as well, it returns ::1.

What's the problem? And how can get the client IP now?

stack
  • 10,280
  • 19
  • 65
  • 117

1 Answers1

2

::1 is just the IPv6 loopback address of the localhost compared to the IPv4 address 127.0.0.1, so it is basically the same host, just a different protocol.

David
  • 3,392
  • 3
  • 36
  • 47
  • Interesting ..! +1. So is everything fine if I upload my website on a real server? I mean is `$_SERVER['SERVER_ADDR']` will return client IP? – stack Jan 06 '16 at 21:46
  • If the loopback address is what you need, it should be fine. However if you need the *client* IP, check this answer: http://stackoverflow.com/a/3003233/213685 – David Jan 06 '16 at 21:49
  • Ah, actually I need to store user's IP to count the number of *viewed* for each post. So how should I get user's IP? – stack Jan 06 '16 at 21:50