|
| $_SERVER['REMOTE_ADDR']
The $_SERVER['REMOTE_ADDR'] variable tells you the ip address of the visitor's machine that is being used to access your page. This has many uses like barring a certain ip address from accessing yor pages or serving up different
content to different countries dynamically, etc.
Use as follows:
echo $_SERVER['REMOTE_ADDR'];
Using the $_SERVER['REMOTE_ADDR'] on this page will output the following (which is the ip from which you are accessing this page):
38.103.63.59
If your visitor is connecting to the internet through a proxy, then the above might show the ip of the proxy and not the true ip of the user's computer. In this case, you can use $_SERVER['HTTP_X_FORWARDED_FOR'] as follows:
echo $_SERVER['HTTP_X_FORWARDED_FOR'];
See also:
|
|