越简单越好!

获取客户端浏览器

发表于 2007-10-08 15:13 | 1177次阅读 0次点赞   PHP

function GetClinetBrowser(){
$Agent = $_SERVER["HTTP_USER_AGENT"];
$browser = '未知';

if(strpos($Agent, "Mozilla")) { $browser = "Mozilla";}
if(strpos($Agent, "Mozilla/4")) { $browser = "Mozilla/4";}
if(strpos($Agent, "Firebird")) { $browser = "Firebird";}
if(strpos($Agent, "Netscape")) { $browser = "Netscape";}
if(strpos($Agent, "Netscape6/")) { $browser = "Netscape6";}
if(strpos($Agent, "Netscape/7.1")) { $browser = "Netscape/7.1";}
if(strpos($Agent, "Opera")) { $browser = "Opera";}
if(strpos($Agent, "Firefox")) { $browser = "Firefox";}
if(strpos($Agent, "Firefox/2.0")) { $browser = "Firefox/2.0";}

//Internet Explorer 5
if(strpos($Agent, "MSIE")) { $browser = "MSIE 未知";}
if(strpos($Agent, "MSIE 7.0")) { $browser = "MSIE 7.0";}
if(strpos($Agent, "MSIE 6.0")) { $browser = "MSIE 6.0";}
if(strpos($Agent, "MSIE 5.5")) { $browser = "MSIE 5.5";}
if(strpos($Agent, "MSIE 5.0")) { $browser = "MSIE 5.0";}
if(strpos($Agent, "MSIE 4.0")) { $browser = "MSIE 4.0";}

return $browser;
}

返回顶部 ^