Php getting IE browser version function _ PHP Tutorial

Source: Internet
Author: User
Tags ereg
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 ,...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.