用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - php代码库

PHP判断当前使用的是什么浏览器

2019-11-05 作者: luckman举报

[php]代码库

判断浏览器类型方法
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; 
}

输出直接调用 userBrowser()
<?php echo "您现在使用的浏览器是:" . userBrowser();?>
本文转载自:https://www.yuncode.net/php/220.html


网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...