获取客户端IP地址:: function getIp(){ if(!empty($_SERVER['HTTP_CLIENT_IP'])){ return $_SERVER['HTTP_CLIENT_IP']; }elseif(!empty($_SERVER['HTTP_X_FORVARDED_FOR'])){ return $_SERVER['HTTP_X_FORVARDED_FOR']; }elseif(!empty($_SERVER['REMOTE_ADDR'])){ return $_SERVER['REMOTE_ADDR']; }else{ return "未知IP"; } 亲,试试我这段代码,获取IP的三种形式 ,应该有一款适合你,根据你的系统,上网方式选择不同的获取方式