Loading

php 获取本机ip

// 执行系统命令获取IP地址
exec('hostname -I | cut -d" " -f1', $output, $return_var);
if ($return_var === 0 && count($output) > 0) {
    $ip = $output[0];
} else {
    $ip = '';
}

 

posted @ 2024-12-12 09:03  Carvers  阅读(25)  评论(0)    收藏  举报