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

How to get client IP in PHP

藏色散人
Release: 2023-03-01 18:30:02
Original
3558 people have browsed it

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template