How do I find my server's IP address in PHP(CLI)

前端 未结 6 1032
梦谈多话
梦谈多话 2020-12-13 09:12

Aside from the obvious (localhost, 127.0.0.1) does PHP (command line interface!) have a mechanism for discovering the IP of the computer the script is running on?

6条回答
  •  执笔经年
    2020-12-13 09:45

    try this it should return the ip address of the server

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

提交回复
热议问题