Home  >  Article  >  Backend Development  >  How to get client IP in PHP

How to get client IP in PHP

藏色散人
藏色散人Original
2020-06-30 10:37:203517browse

In PHP, you can use the "$_SERVER" method to obtain the client IP. The complete syntax is "$_SERVER['REMOTE_ADDR']". By executing this method, you can browse the IP address of the user on the current page.

How to get client IP in PHP

PHP gets client IP

##Client IP: $_SERVER['REMOTE_ADDR']

$_SERVER['REMOTE_ADDR'] The IP address of the user browsing the current page.

$_SERVER['REMOTE_HOST'] The host name of the user browsing the current page. DNS reverse resolution does not depend on the user's REMOTE_ADDR.

$_SERVER['REMOTE_PORT'] The port number used on the user's machine to connect to the web server.

Please check the relevant manual content of super global variables for details:

https://www.php.cn/php/php-superglobals.html

The above is the detailed content of How to get client IP in PHP. For more information, please follow other related articles on the PHP Chinese website!

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