How to Get IP Address of Visitor with PHP

This is a simple PHP tutorials and script for getting remote visitors with their IP Address. With this tracking your visitor is very easy and simple with PHP. PHP has a set of global variables. Among them, we use $_SERVER variable to get an IP address of a remote computer. REMOTE_ADDR is the constant that is used to get the IP Address of a remote computer.

Note that this script may not return IP Address if the client/user firewall is on or when client is using some proxy software.

Another way of retrieving IP Address is using function getenv().


OUTPUT Example

Server IP ADDRESS: 124.41.196.203
User IP ADDRESS: 202.79.40.133
User HOST ADDRESS: 203.196.41.124.dynamic.wlink.com.np

Note: $userip is the IP address of the user thats been passed on by the server. $proxy is the IP address of the server itself and $host is the host address of the user. If your PHP version is less than 4.3 then use $HTTP_SERVER_VARS in place of $_SERVER

Ashesh

सयौ थुङ्गा फूलका हामी एउटै माला नेपाली, Welcome to my webpage. I'm from the Himalayan Country of Nepal. Well talking about me, I like mostly Web programming and Designing and furthermore I like Philosophical literature, Photography, Social networking. And I am Romantic and Sentimental person to some extent. Read more...