显示服务器IP地址

2025-3-27 / 0 评论 / 4 阅读

<?php
function serverIp(){
if(isset(\$_SERVER)){
if(\$_SERVER['SERVER_ADDR']){
\$server_ip=\$_SERVER['SERVER_ADDR'];
}else{
\$server_ip=\$_SERVER['LOCAL_ADDR'];
}
}else{
\$server_ip = getenv('SERVER_ADDR');
}
return \$server_ip;
}

echo serverIp();
?>