How to identify server IP address in PHP

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

How can I identify the server IP address in PHP?

相关标签:
15条回答
  • 2020-11-30 00:18

    Like this for the server ip:

    $_SERVER['SERVER_ADDR'];
    

    and this for the port

    $_SERVER['SERVER_PORT'];
    
    0 讨论(0)
  • 2020-11-30 00:20

    for example:

    $_SERVER['SERVER_ADDR']
    

    when your on IIS, try:

    $_SERVER['LOCAL_ADDR']
    
    0 讨论(0)
  • 2020-11-30 00:20

    I found this to work for me: GetHostByName("");

    Running XAMPP v1.7.1 on Windows 7 running Apache webserver. Unfortunately it just give my gateway IP address.

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