Getting real IP address in PHP

Post Date: Nov 16 2008
Total Visit: 6304

Generally you are used $_SERVER['REMOTE_ADDR'] to find out the client's IP address in PHP. But it may not return the true IP address of the client at all time. If your client is connect to the Internet through Proxy Server then $_SERVER['REMOTE_ADDR'] in PHP just returns the IP address of the Proxy Server not of the client's machine. So here is a simple function in PHP to find out the real IP address of the client's machine. There are extra Server variable which might be available to determine the exact IP address of the client's machine in PHP, they are HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR.

To do articles more effectively, we need your comments or suggestions on how to improve the articles and make it more useful, or what other articles you would like in the future. Please CLICK HERE and leave your feedback. Thanks!!!