PHP simply determines what browser is currently in use

Time:2019-11-29

PHP is a simple way to judge what browser is currently used and the type of browser. It is convenient to count the proportion of Web site users using the browser.

Judge browser type method

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

Call userbrowser() directly

This article from: https://www.sucaihoo.com/php/220.html reprint please indicate the source!