Dragen Posted September 22, 2007 Share Posted September 22, 2007 Hi, Could someone please tell me what all of these $+SERVER variables mean and/or do? I've been searching for a bit and can't seem to find anything, even on php.net's predefined variable list and I'm trying to find ways of logging ip's, browser versions etc. $HTTP_X_FORWARDED_FOR $HTTP_VIA $HTTP_CLIENT_IP $HTTP_PROXY_CONNECTION $FORWARDED_FOR $X_FORWARDED_FOR $X_HTTP_FORWARDED_FOR $HTTP_FORWARDED None of them actually seem to work on my local server I receive this kind of error: Notice: Undefined index: FORWARDED_FOR in C:\Program Files\wamp\www\counter.php on line 13 I'm presuming this is either because I don't have those server variables installed/enabled or they don't actually exist and have just sprouted up among the internet as a means of distracting us... any help would be great! Quote Link to comment https://forums.phpfreaks.com/topic/70292-help-understanding-some-_server-variables/ Share on other sites More sharing options...
pocobueno1388 Posted September 22, 2007 Share Posted September 22, 2007 If you just put this in you code: <?php echo '<pre>'; print_r($_SERVER); echo '</pre>'; ?> That will give a list of all the server variables, and what values they hold for that specific page. To get an IP address, use $_SERVER['REMOTE_ADDR']; Quote Link to comment https://forums.phpfreaks.com/topic/70292-help-understanding-some-_server-variables/#findComment-353095 Share on other sites More sharing options...
Dragen Posted September 22, 2007 Author Share Posted September 22, 2007 Thanks. The main one I undrstand are these two: $_SERVER['REMOTE_ADDR']; //get ip gethostbyaddr($_SERVER['REMOTE_ADDR']); //get ip hostname $_SERVER['HTTP_REFERER']; //page referer There was another way of getting the ip hostname, but I can't use it on my local server. I'm just trying to figure out what the other's do, so I can decide if it's worth the hasle of trying to get them to work.. if I can. Quote Link to comment https://forums.phpfreaks.com/topic/70292-help-understanding-some-_server-variables/#findComment-353101 Share on other sites More sharing options...
trq Posted September 22, 2007 Share Posted September 22, 2007 Here is a list describing all the server variables and what they do. Quote Link to comment https://forums.phpfreaks.com/topic/70292-help-understanding-some-_server-variables/#findComment-353103 Share on other sites More sharing options...
Dragen Posted September 22, 2007 Author Share Posted September 22, 2007 I've already searched through that. None of them are listed on there, although a couple of people have used them in code examples, but no explaining what they do. Also, how do I go about enabling the use of server values that aren't enabled at the moment? Quote Link to comment https://forums.phpfreaks.com/topic/70292-help-understanding-some-_server-variables/#findComment-353107 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.