PHP display server IP Address

后端 未结 3 2030
野趣味
野趣味 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.

    0 讨论(0)
  • 2021-02-05 07:13

    If your laravel application is running on an internal server, you can use the following to get the external address of the server:

     $external_ip = exec('curl http://ipecho.net/plain; echo');
    
    0 讨论(0)
  • 2021-02-05 07:25

    for server ip address $_SERVER['SERVER_ADDR'];

    and for server port $_SERVER['SERVER_PORT'];

    0 讨论(0)
提交回复
热议问题