PHP简单判断当前使用的是什么浏览器
程序员文章站
2022-05-09 14:13:07
PHP简单判断当前使用的是什么浏览器,判断浏览器类型的方法,方便统计网站访问用户使用浏览器的比例。 ......
php简单判断当前使用的是什么浏览器,判断浏览器类型的方法,方便统计网站访问用户使用浏览器的比例。
判断浏览器类型方法
1 function userbrowser() { 2 $user_osagent = $_server['http_user_agent']; 3 4 if (strpos($user_osagent, "maxthon") && strpos($user_osagent, "msie")) { 5 $visitor_browser = "maxthon(microsoft ie)"; 6 } elseif (strpos($user_osagent, "maxthon 2.0")) { 7 $visitor_browser = "maxthon 2.0"; 8 } elseif (strpos($user_osagent, "maxthon")) { 9 $visitor_browser = "maxthon"; 10 } elseif (strpos($user_osagent, "msie 9.0")) { 11 $visitor_browser = "msie 9.0"; 12 } elseif (strpos($user_osagent, "msie 8.0")) { 13 $visitor_browser = "msie 8.0"; 14 } elseif (strpos($user_osagent, "msie 7.0")) { 15 $visitor_browser = "msie 7.0"; 16 } elseif (strpos($user_osagent, "msie 6.0")) { 17 $visitor_browser = "msie 6.0"; 18 } elseif (strpos($user_osagent, "msie 5.5")) { 19 $visitor_browser = "msie 5.5"; 20 } elseif (strpos($user_osagent, "msie 5.0")) { 21 $visitor_browser = "msie 5.0"; 22 } elseif (strpos($user_osagent, "msie 4.01")) { 23 $visitor_browser = "msie 4.01"; 24 } elseif (strpos($user_osagent, "msie")) { 25 $visitor_browser = "msie 较高版本"; 26 } elseif (strpos($user_osagent, "netcaptor")) { 27 $visitor_browser = "netcaptor"; 28 } elseif (strpos($user_osagent, "netscape")) { 29 $visitor_browser = "netscape"; 30 } elseif (strpos($user_osagent, "chrome")) { 31 $visitor_browser = "chrome"; 32 } elseif (strpos($user_osagent, "lynx")) { 33 $visitor_browser = "lynx"; 34 } elseif (strpos($user_osagent, "opera")) { 35 $visitor_browser = "opera"; 36 } elseif (strpos($user_osagent, "konqueror")) { 37 $visitor_browser = "konqueror"; 38 } elseif (strpos($user_osagent, "mozilla/5.0")) { 39 $visitor_browser = "mozilla"; 40 } elseif (strpos($user_osagent, "firefox")) { 41 $visitor_browser = "firefox"; 42 } elseif (strpos($user_osagent, "u")) { 43 $visitor_browser = "firefox"; 44 } else { 45 $visitor_browser = "其它"; 46 } 47 return $visitor_browser; 48 }
直接调用 userbrowser()
<?php echo "您现在使用的浏览器是:" . userbrowser();?>
本文转自: 转载请注明出处!