PHP display server IP Address

后端 未结 3 2032
野趣味
野趣味 2021-02-05 06:50

I\'m working on a website, and one of the things I would like to do is display MY IP address to users. The website is made with CodeIgniter, so I was looking to find my server

3条回答
  •  野的像风
    2021-02-05 07:13

    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.

提交回复
热议问题