How do I get the external IP of my server using PHP?

后端 未结 12 2662
后悔当初
后悔当初 2020-11-30 07:47

I often hear people say to use \"$_SERVER[\'SERVER_ADDR\']\", but that returns the LAN IP of my server (e.g. 192.168.1.100). I want the external IP.

12条回答
  •  孤街浪徒
    2020-11-30 08:19

    You could parse it from a service like ip6.me:

    \r\n
    Full results from ip6.me:\r\n
    "; echo $file;

提交回复
热议问题