How to identify server IP address in PHP

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

How can I identify the server IP address in PHP?

15条回答
  •  眼角桃花
    2020-11-30 00:14

    If you are using PHP version 5.3 or higher you can do the following:

    $host= gethostname();
    $ip = gethostbyname($host);
    

    This works well when you are running a stand-alone script, not running through the web server.

提交回复
热议问题