Get the App
SLTechnology News&Howtos  ›  Development  › 

How does PHP determine the type of browser currently in use

Shulou Source: shulou.com Published: 2022-06-03 19:03:39 10月05日 Update

This article mainly introduces "how to judge the type of browser currently used by PHP". In daily operation, I believe many people have doubts about how to judge the type of browser currently used by PHP. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubt of "how to judge the type of browser currently used by PHP". Next, please follow the editor to study!

Method of judging browser type

Function userBrowser () {$user_OSagent = $_ SERVER ['HTTP_USER_AGENT']; if (strpos ($user_OSagent, "Maxthon") & & strpos ($user_OSagent, "MSIE")) {$visitor_browser = "Maxthon (Microsoft IE)";} elseif (strpos ($user_OSagent, "Maxthon 2.0")) {$visitor_browser = "Maxthon 2.0" } elseif (strpos ($user_OSagent, "Maxthon")) {$visitor_browser = "Maxthon";} elseif (strpos ($user_OSagent, "MSIE 9.0")) {$visitor_browser = "MSIE 9.0";} elseif (strpos ($user_OSagent, "MSIE 8.0")) {$visitor_browser = "MSIE 8.0" } elseif (strpos ($user_OSagent, "MSIE 7.0")) {$visitor_browser = "MSIE 7.0";} elseif (strpos ($user_OSagent," MSIE 6.0")) {$visitor_browser = "MSIE 6.0";} elseif (strpos ($user_OSagent," MSIE 5.5")) {$visitor_browser = "MSIE 5.5" } elseif (strpos ($user_OSagent, "MSIE 5.0n") {$visitor_browser = "MSIE 5.01";} elseif (strpos ($user_OSagent," MSIE 4.01")) {$visitor_browser = "MSIE 4.01";} elseif (strpos ($user_OSagent," MSIE ")) {$visitor_browser =" MSIE later " } elseif (strpos ($user_OSagent, "NetCaptor")) {$visitor_browser = "NetCaptor";} elseif (strpos ($user_OSagent, "Netscape")) {$visitor_browser = "Netscape";} elseif (strpos ($user_OSagent, "Chrome")) {$visitor_browser = "Chrome";} elseif (strpos ($user_OSagent, "Lynx")) {$visitor_browser = "Lynx" } elseif (strpos ($user_OSagent, "Opera")) {$visitor_browser = "Opera";} elseif (strpos ($user_OSagent, "Konqueror")) {$visitor_browser = "Konqueror";} elseif (strpos ($user_OSagent, "Mozilla/5.0")) {$visitor_browser = "Mozilla";} elseif (strpos ($user_OSagent, "Firefox")) {$visitor_browser = "Firefox" } elseif (strpos ($user_OSagent, "U")) {$visitor_browser = "Firefox";} else {$visitor_browser = "other";} return $visitor_browser;}

Call userBrowser () directly

At this point, the study on "how PHP determines the type of browser currently in use" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Browsers types browsing learning methods more help practical next articles versions theories knowledge articles websites materials follow questions easy to use practice Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Tech Info Xiaomi Microsoft MariaDB