获取浏览器

//获取浏览器

function GetBrowser(){

if(!empty($_SERVER['HTTP_USER_AGENT'])){

$br = $_SERVER['HTTP_USER_AGENT'];

if (preg_match('/MSIE/i',$br)) {

$br = 'MSIE';

}elseif (preg_match('/Firefox/i',$br)) {

$br = 'Firefox';

}elseif (preg_match('/Chrome/i',$br)) {

$br = 'Chrome';

}elseif (preg_match('/Safari/i',$br)) {

$br = 'Safari';

}elseif (preg_match('/Opera/i',$br)) {

$br = 'Opera';

}else {

$br = 'Other';

}

return $br;

}else{return "获取浏览器信息失败!";}

}

你可能感兴趣的:(获取浏览器)