Home  >  Article  >  Backend Development  >  How to get the real IP address of the remote client in PHP_PHP Tutorial

How to get the real IP address of the remote client in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:25:45670browse

(1).REMOTE_ADDR: The ip address of the user's computer browsing the current page

(2).HTTP_X_FORWARDED_FOR: The gateway of the user's computer browsing the current page

(3).HTTP_CLIENT_IP: Client's ip

Use $_SERVER["REMOTE_ADDR"] in PHP to get the client's IP address. However, if the client uses a proxy server to access, what you get is the IP address of the proxy server, not the real one. Client IP address. To obtain the client's real IP address through a proxy server, use $_SERVER["HTTP_X_FORWARDED_FOR"] to read it.

However, something to note is that not every proxy server can use $_SERVER["HTTP_X_FORWARDED_FOR"] to read the real IP of the client. Some of the IPs read by this method are still the IP of the proxy server. .

Another thing to note is that if the client does not access through a proxy server, the value obtained with $_SERVER["HTTP_X_FORWARDED_FOR"] will be empty.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324054.htmlTechArticle(1).REMOTE_ADDR: The IP address of the user’s computer browsing the current page (2).HTTP_X_FORWARDED_FOR: Browsing the current page The gateway of the user's computer (3).HTTP_CLIENT_IP: The client's ip is used in PHP...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn