首页 > PHP
ThinkPHP6获取IP地址
来源:TP课堂 时间:2022-12-10 点击:3791
function getRealIP(){
        $forwarded = request()->header("x-forwarded-for");
        if($forwarded){
            $ip = explode(',',$forwarded)[0];
        }else{
            $ip = request()->ip();
        }
        return $ip;
    }