php获取客户IP
获取客户真实IP,保存到数据库建议转整
function getIp(){ $ip = ''; if(!empty($_SERVER['HTTP_CLIENT_IP'])){ $ip = $_SERVER['HTTP_CLIENT_IP']; }else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){ $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; }else if(!empty($_SERVER['REMOTE_ADDR'])){ $ip = $_SERVER['REMOTE_ADDR']; }else{ $ip = ''; } return bindec(decbin(ip2long($ip))); }