日期:2014-05-17  浏览次数:20501 次

php 获取浏览器名称

if (strpos($_SERVER[HTTP_USER_AGENT], 'Maxthon')) {
??? $browser = 'Maxthon';
} elseif(strpos($_SERVER[HTTP_USER_AGENT], 'MSIE 8.0')) {
??? $browser = 'MSIE 8.0';
} elseif(strpos($_SERVER[HTTP_USER_AGENT], 'MSIE 7.0')) {
??? $browser = 'MSIE 7.0';
} elseif(strpos($_SERVER[HTTP_USER_AGENT], 'MSIE 6.0')) {
??? $browser = 'MSIE 6.0';
} elseif(strpos($_SERVER[HTTP_USER_AGENT], 'NetCaptor')) {
??? $browser = 'NetCaptor';
} elseif(strpos($_SERVER[HTTP_USER_AGENT], 'Netscape')) {
??? $browser = 'Netscape';
} elseif(strpos($_SERVER[HTTP_USER_AGENT], 'Lynx')) {
??? $browser = 'Lynx';
} elseif(strpos($_SERVER[HTTP_USER_AGENT], 'Opera')) {
??? $browser = 'Opera';
} elseif(strpos($_SERVER[HTTP_USER_AGENT], 'Konqueror')) {
??? $browser = 'Konqueror';
} elseif(strpos($_SERVER[HTTP_USER_AGENT], 'Firefox')) {
??? $browser = 'Firefox';
} elseif(strpos($_SERVER[HTTP_USER_AGENT],'Safari')) {
??? $browser = 'Safari';
} else {
??? $browser = 'other';
}
echo $browser;