PHP获取IP的方法

function getIP() { 
    if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { 
        $realip = $_SERVER['HTTP_X_FORWARDED_FOR']; 
    } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) { 
        $realip = $_SERVER['HTTP_CLIENT_IP']; 
    } else { 
        $realip = $_SERVER['REMOTE_ADDR']; 
        } 
        return $realip; 
    }

 



posted @ 2017-08-21 15:02  郁冬  阅读(453)  评论(0编辑  收藏  举报