tags:

views:

79

answers:

2

Any real difference between

$_SERVER['REMOTE_ADDR']
$_SERVER['SERVER_ADDR']

I'm tracking visitors to a page, and I've always used REMOTE_ADDR, but recently I saw a script that collected both information. Is this a better practice or not needed?

+5  A: 

SERVER_ADDR is the address of the server PHP code is run on. You don't need to collect it. REMOTE_ADDR is the one you want.

jmz
SERVER_ADDR would only be relevant if the site's hosted on multiple servers and you're interested in exactly which server handled the request.
Marc B
`SERVER` / `REMOTE` are self explanatory :/
RobertPitt
+7  A: 

The $_SERVER['REMOTE_ADDR'] returns the IP address from which the user is viewing the current page. And $_SERVER['SERVER_ADDR'] returns the IP address of the server under which the current script is executing.

So what should you use:

You should use $_SERVER['REMOTE_ADDR'].

More Info:

Sarfraz