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. .
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!