Find IP address, referrer, uri , operating system using php

By Published On: February 8, 2011

Today i will teach you how to find IP address, referrer, uri , operating system using php. We will use $_SERVER to get all this information. $_SERVER[‘HTTP_REFERER’] is used to get the url of the page that refered the user to the current location. $_SERVER[‘REMOTE_ADDR’] is used the get the client IP address $_SERVER[‘REQUEST_URI’] is used to get the uri of the URL. For example the uri of [...]


Today i will teach you how to find IP address, referrer, uri , operating system using php. We will use $_SERVER to get all this information.

Php Information

Php Information

$_SERVER[‘HTTP_REFERER’] is used to get the url of the page that refered the user to the current location.
$_SERVER[‘REMOTE_ADDR’] is used the get the client IP address
$_SERVER[‘REQUEST_URI’] is used to get the uri of the URL. For example the uri of http://localhost/mysite/index.php is /mysite/index.php/
$_SERVER[‘HTTP_USER_AGENT’] is used to get the user agent to the client for example you are using firefox or ie. It also tells that which operation system you are using.

You can see more $_SERVER predefined variables by using the following code as below:

[code lang=”php”]

foreach ($_SERVER as $var => $value) {
echo "$var => $value";
}

[/code]


Share this article

Written by : Junaid Rehman

I am a blogger and freelance web developer by profession. I love to blog and learn new things about programming and IT World.

Follow us

A quick overview of the topics covered in this article.

Join our website

Our partner website gives you a good reading experience

Latest articles