Home > Backend Development > PHP Problem > How to get the server IP in PHP

How to get the server IP in PHP

藏色散人
Release: 2023-03-01 18:32:01
Original
6613 people have browsed it

In PHP, you can use the "$_SERVER" method to obtain the server IP. Its complete syntax is "$_SERVER['SERVER_ADDR']". Execute this method to obtain the IP address of the server where the script is currently running. .

How to get the server IP in PHP

PHP Get server IP

##Server IP:

$_SERVER['SERVER_ADDR ']

$_SERVER['SERVER_ADDR'] The IP address of the server where the script is currently running.

$_SERVER['SERVER_NAME'] The host name of the server where the script is currently running. If the script is running on a virtual host, the name is determined by the value set for that virtual host. (For example: m.sbmmt.com)

$_SERVER['SERVER_SOFTWARE'] Server identification string, given in the header information when responding to the request. (For example: Apache/2.2.24)

$_SERVER['SERVER_PROTOCOL'] The name and version of the communication protocol when requesting the page. For example, "HTTP/1.0".

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 the server 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