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.
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!