首页 | 新闻 | 交流 | 问吧 | 文档 | 手册 | 下载 | 博客

php获取访问的ip

作者:  时间: 2011-05-17

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