How to get the currently visited IP address in PHP

藏色散人
Release: 2019-11-23 13:51:56
Original
19966 people have browsed it

In the previous article "How to obtain browser information in PHP", we showed you how to obtain it through the super global variable $_SERVER in PHP. Then PHP obtains the currently accessed IP address, we can still use $_SERVER to achieve IP acquisition.

How to get the currently visited IP address in PHP

IP Address: An Internet Protocol address (IP address) is a numerical label assigned to every device connected to a computer network that communicates using the Internet Protocol. An IP address has two main functions: host or network interface identification and location addressing.

Recommended manual: php complete self-study manual

Below we will combine simple code examples to introduce PHP to obtain the currently accessed IP address. Methods.

The code example is as follows:

Copy after login

Since we are testing locally, the current IP address obtained:

127.0.0.1
Copy after login

Note: $_SERVER is a An array of information such as headers, paths, and script locations.

Recommended related articles:
1. How to get the user’s IP address in php
2. How does php get the client’s IP address?
Related video recommendations:
1. Dugu Jiujian (4)_PHP video tutorial

This article is about An introduction to the method of obtaining the currently accessed IP address in PHP. It is very simple. I hope it will be helpful to friends in need!

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

Related labels:
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!