Nxt Posted September 25, 2008 Share Posted September 25, 2008 Hey! Okay, I made this basic script that was support to obtain the visitor's IP address. I thought if you did this it would: $ip = $_SERVER['HTTP_CLIENT_IP']; I have it echo it out. echo("Hello, user-you're IP is :".$ip); however it displays: Hello, User-you're IP is: and nothing else after that. What am I doing that? Help would be greatly appreciated! Thanks! -NxT Link to comment https://forums.phpfreaks.com/topic/125705-how-do-i-get-an-ip-address-from-a-visitor/ Share on other sites More sharing options...
Asheeown Posted September 25, 2008 Share Posted September 25, 2008 $IP = $_SERVER['REMOTE_ADDR']; echo("Hello user your IP is: $IP"); Link to comment https://forums.phpfreaks.com/topic/125705-how-do-i-get-an-ip-address-from-a-visitor/#findComment-649977 Share on other sites More sharing options...
rarebit Posted September 25, 2008 Share Posted September 25, 2008 as FearSoldier states, but you can see all the server (or other) vars by doing something like this (useful if you don't have the docs): while (list($k, $v) = each($_SERVER)) { print "'".$k."' => '".$v."' <br>"; } Link to comment https://forums.phpfreaks.com/topic/125705-how-do-i-get-an-ip-address-from-a-visitor/#findComment-649982 Share on other sites More sharing options...
Guest Xanza Posted September 25, 2008 Share Posted September 25, 2008 $IP = $_SERVER['REMOTE_ADDR']; echo("Hello user your IP is: $IP"); This will work, the reason why yours dident work is because of the period before $ip. Link to comment https://forums.phpfreaks.com/topic/125705-how-do-i-get-an-ip-address-from-a-visitor/#findComment-649987 Share on other sites More sharing options...
Asheeown Posted September 25, 2008 Share Posted September 25, 2008 The period indicates continuation in the string, no? Link to comment https://forums.phpfreaks.com/topic/125705-how-do-i-get-an-ip-address-from-a-visitor/#findComment-649994 Share on other sites More sharing options...
rarebit Posted September 25, 2008 Share Posted September 25, 2008 The period was ok, but i'm assuming that 'HTTP_CLIENT_IP' is from the old deprecated $HTTP_SERVER_VARS, now replaced by $_SERVER, see Link to comment https://forums.phpfreaks.com/topic/125705-how-do-i-get-an-ip-address-from-a-visitor/#findComment-649995 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.