开发者

Which to use: REMOTE_ADDR or SERVER_ADDR

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?


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:

  • http://php.net/manual/en/reserved.variables.server.php


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.


IP to use for API and online payment gateway: $ _SERVER ['SERVER_ADDR']

Returns the user's address from which they are viewing the current page $_SERVER ['REMOTE_ADDR'];

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜