Get Remote IP Address in PHP

PHP
Razet · · 3012 Views

Are you using $_SERVER['REMOTE_ADDR'] to get the client’s IP address in PHP? Well, you may be stunned to know that it may not give the true IP address of the client at all times. If the client is connected with the Internet through Proxy Server, at that point $_SERVER['REMOTE_ADDR'] in PHP returns the IP address of the proxy server not of the client’s machine. So here is a basic function in PHP to locate the real IP address of the client’s machine. There are some additional Server variables which may be accessible to determine the specific IP address of the client’s machine in PHP, they are HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR.

Get Remote IP Address in PHP

0

Please login or create new account to add your comment.

0 comments
You may also like: