How to identify server IP address in PHP

后端 未结 15 961
温柔的废话
温柔的废话 2020-11-29 23:52

How can I identify the server IP address in PHP?

15条回答
  •  日久生厌
    2020-11-30 00:09

    If you are using PHP in bash shell you can use:

    $server_name=exec('hostname');
    

    Because $_SERVER[] SERVER_ADDR, HTTP_HOST and SERVER_NAME are not set.

提交回复
热议问题