How do I get my system's IP address?
I am using $ip_address=$_SERVER[REMOTE_ADDR];
, but it returns my localhost IP address instead of my system's IP address.
How do I get my system's IP address?
I am using $ip_address=$_SERVER[REMOTE_ADDR];
, but it returns my localhost IP address instead of my system's IP address.
This function will determine the real IP address:
If you are accessing a local server, then your local IP address is the remote IP. PHP is giving you the correct response.
If you want to know your IP address to the rest of the internet, go to Google and type "what is my ip".
A late reply but I hope it still might be able to help someone. I needed system ip for a project so I quickly scrapped up a custom function using regular expressions. It works on ubuntu linux (and technically should work on any distro/version of linux).
It requires:
If you happen to create something similar for windows or improve the functionality of this function, please share your code with the rest of us.
$_SERVER['SERVER_ADDR']
See the php docs for a full list of stuff you might find in the
$_SERVER
superglobal.