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:
//m.sbmmt.com/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