Bman900 Posted May 11, 2009 Share Posted May 11, 2009 I want to print out the user's ip on the screen like: Your IP adress is: XXXXXXXXXXXXX Does php have a function for this? Quote Link to comment https://forums.phpfreaks.com/topic/157748-how-to-display-users-ip/ Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 str_replace('.','',getenv('REMOTE_ADDR')); Quote Link to comment https://forums.phpfreaks.com/topic/157748-how-to-display-users-ip/#findComment-832035 Share on other sites More sharing options...
.josh Posted May 11, 2009 Share Posted May 11, 2009 getenv only works on apache servers. So if you are using IIS it won't work. Use $_SERVER['REMOTE_ADDR'] instead, as it works across different servers. Quote Link to comment https://forums.phpfreaks.com/topic/157748-how-to-display-users-ip/#findComment-832041 Share on other sites More sharing options...
Bman900 Posted May 11, 2009 Author Share Posted May 11, 2009 getenv only works on apache servers. So if you are using IIS it won't work. Use $_SERVER['REMOTE_ADDR'] instead, as it works across different servers. Thank you, works like a charm! Quote Link to comment https://forums.phpfreaks.com/topic/157748-how-to-display-users-ip/#findComment-832049 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.