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? 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')); 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. 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! 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
Archived
This topic is now archived and is closed to further replies.