$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
if($agent){
$broswer = ''; $version = '';
if(strpos($agent,"chrome")){
$version = stristr($agent,"chrome");
$version = stristr($version,"safari",true);
$version = substr($version,7);
$broswer = '谷歌Chrome';
}else if(strpos($agent,"firefox")){
$version = strrchr($agent,"/");
$version = substr($version,1);
$broswer = '火狐Firefox';
}else if(strpos($agent,"trident")){
$version = stristr($agent,"trident");
if(strpos($agent,"rv:11.0")){
$broswer = '微软IE11';
$version = stristr($version,";",true);
}else if(strpos($agent,"msie 10.0")){
$broswer = '微软IE10';
$version = stristr($version,")",true);
}else if(strpos($agent,"msie 9.0")){
$broswer = '微软IE9';
$version = stristr($version,")",true);
}else if(strpos($agent,"msie 8.0")){
$broswer = '微软IE8';
$version = stristr($version,")",true);
}
}
if($broswer && $version){
echo '你的浏览器为'.$broswer.'浏览器,版本为:'.$version;
}else{
echo $agent;
}
}else{
echo 'unknown your browser !!!';
}
if($agent){
$broswer = ''; $version = '';
if(strpos($agent,"chrome")){
$version = stristr($agent,"chrome");
$version = stristr($version,"safari",true);
$version = substr($version,7);
$broswer = '谷歌Chrome';
}else if(strpos($agent,"firefox")){
$version = strrchr($agent,"/");
$version = substr($version,1);
$broswer = '火狐Firefox';
}else if(strpos($agent,"trident")){
$version = stristr($agent,"trident");
if(strpos($agent,"rv:11.0")){
$broswer = '微软IE11';
$version = stristr($version,";",true);
}else if(strpos($agent,"msie 10.0")){
$broswer = '微软IE10';
$version = stristr($version,")",true);
}else if(strpos($agent,"msie 9.0")){
$broswer = '微软IE9';
$version = stristr($version,")",true);
}else if(strpos($agent,"msie 8.0")){
$broswer = '微软IE8';
$version = stristr($version,")",true);
}
}
if($broswer && $version){
echo '你的浏览器为'.$broswer.'浏览器,版本为:'.$version;
}else{
echo $agent;
}
}else{
echo 'unknown your browser !!!';
}