search
Homephp教程php手册php获取IE浏览器版本函数

php获取IE浏览器版本函数

Jun 13, 2016 am 10:16 AM
phpsuseinformationfunctionCanexistusBrowserVersionObtainwant

在php中我们要获取浏览器信息可以直接使用$userAgent = strtolower($_SERVER[\"HTTP_USER_AGENT\"]);然后再判断一下就可以判断用户浏览器版本或型号了,希望下面的实例对大家有所帮助。

下面笔者为各位介绍一款如何判断用户浏览器是不是IE6的php函数,如果是返回“真”,否则返回“假”。

 代码如下 复制代码

function isIE6() {
       $userAgent = strtolower($_SERVER["HTTP_USER_AGENT"]);
       //从HTTP_USER_AGENT字段中获取用户浏览器信息
       if (ereg("msie 6", $userAgent) || ereg("msie 5", $userAgent)) {
               return true;
       }
       return false;
}

完整点的实例

 代码如下 复制代码

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 ="MSIE 较高版本";  
      }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 ="其它";  
        }  
           return $visitor_browser;  
       } 

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.