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

How to get the server IP in PHP

藏色散人
藏色散人Original
2020-06-30 10:41:216522browse

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: www.php.cn)

$_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:

https://www.php.cn/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!

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