Shouldn't the value match the IP of the computer that's requesting the script regardless of the fact that it's the same computer that's hosting the script?
migrated from stackoverflow.com Aug 26 '11 at 17:59
This question came from our site for professional and enthusiast programmers.
|show 2 more comments|
Because when you run PHP locally every request you make will come from your machine, which happens to have a remote (or in this case, local) address of... wait for it.... 127.0.0.1 (== localhost).
Elaboration: Let's assume for a second you have no internet connection, nothing at all, no WiFi, no cable. The local connection would still work. Why? because it would be stupid to require internet connection for local affairs. Instead, the connection comes from the server itself which means, you will see
|show 6 more comments|
The reason for this is that you're talking to 127.0.0.1.
When talking to a network device (local machine or otherwise), packets has to have a source address, and an address is picked that will be available in the network you're communicating over.
So the source address used depends on the target address being communicated with.
Since the server is reporting that you're coming from 127.0.0.1, you will have to be talking to 127.0.0.1, because that's the only target address where that source address would've been picked.
If you had talked to your machine using its IPv6 local address (
However, in order to see the
You can try that by simply replacing the hostname or localhost or whatever you wrote in the URL with
My guess is that you're doing
It is a local connection.
The connection is being made locally. You local IP address for your localhost is 127.0.0.1.
No connections are being made through any other network other than your localhost.