获取服务器内网IP:
$ip = getHostByName(getHostName()); echo $ip;
获取服务器公网IP:
$ip = file_get_contents('https://api.ipify.org'); echo $ip;