Php obtains functions of the IE browser version. To obtain browser information in php, you can directly use $ userAgentstrtolower ($ _ SERVER [HTTP_USER_AGENT]). then, you can determine the version or model of your browser, to obtain browser information in php, use $ userAgent = strtolower ($ _ SERVER [\ "HTTP_USER_AGENT \"]). then you can judge the version or model of your browser. I hope the following instances will help you.
Next I will introduce you to a php function that determines whether your browser is IE6. if "true" is returned, otherwise "false" is returned ".
The code is as follows: |
|
Function isIE6 (){ $ UserAgent = strtolower ($ _ SERVER ["HTTP_USER_AGENT"]); // Obtain the user's browser information from the HTTP_USER_AGENT field If (ereg ("msie 6", $ userAgent) | ereg ("msie 5", $ userAgent )){ Return true; } Return false; } |
Complete instance
The code is as follows: |
|
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.0 ")){ $ Visitor_browser = "MSIE 5.0 "; } Elseif (strpos ($ user_OSagent, "MSIE 4.01 ")){ $ Visitor_browser = "MSIE 4.01 "; } Elseif (strpos ($ user_OSagent, "MSIE ")){ $ Visitor_browser = "higher MSIE version "; } 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 = "others "; } Return $ visitor_browser; } |
Connector = strtolower ($ _ SERVER [\ "HTTP_USER_AGENT \"]); then you can judge the version or model of your browser ,...