PHP

 Home  Computers & Internet  Web Programming PHP
What is PHP?
Echo
Comments
Variables
Constants
Data Types
number_format()
Character Strings
Mathematical Operators
Comparison Operators
Logical Operators
Joining Strings
explode()
implode()
strtolower()
strtoupper()
strlen()
ucfirst()
ucwords()
strrev()
str_replace()
str_repeat()
trim()
strip_tags()
addslashes()
stripslashes()
strpos()
strrpos()
nl2br()
isset()
unset()
empty()
POST
GET
If Statements
If Else Statements
Elseif Statements
Switch Statements
For Loops
While Loops
Do While Loops
Foreach Loops
File Create
File Open
File Read
File Write
File Delete
fgets()
file_get_contents()
Date & Time
$_SERVER
Sessions
Cookies
Arrays

$_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:

$_SERVER['HTTP_REFERER']
$_SERVER['HTTP_USER_AGENT']
$_SERVER['PHP_SELF']
$_SERVER['REQUEST_URI']
$_SERVER['DOCUMENT_ROOT']
$_SERVER['HTTP_HOST']
$_SERVER['QUERY_STRING']
$_SERVER['SCRIPT_FILENAME']




Home | Privacy Policy | Terms Of Use | Contact Us