PHP display server IP Address
Try $_SERVER['SERVER_ADDR']
. It will be the IP address that the server is listening on. You can use DNS functions (e.g., gethostbyaddr()
) to get the host name.
See http://www.php.net/manual/en/reserved.variables.server.php.
for server ip address $_SERVER['SERVER_ADDR'];
and for server port $_SERVER['SERVER_PORT'];