zoukankan      html  css  js  c++  java
  • php:获取浏览器的版本信息

    //分析返回用户网页浏览器名称,返回的数组第一个为浏览器名称,第二个是版本号。

     function getBrowser() {
         $sys $_SERVER['HTTP_USER_AGENT'];
         if (stripos($sys"NetCaptor") > 0) {
             $exp[0] = "NetCaptor";
             $exp[1] = "";
         elseif (stripos($sys"Firefox/") > 0) {
             preg_match("/Firefox/([^;)]+)+/i"$sys$b);
             $exp[0] = "Mozilla Firefox";
             $exp[1] = $b[1];
         elseif (stripos($sys"MAXTHON") > 0) {
             preg_match("/MAXTHONs+([^;)]+)+/i"$sys$b);
             preg_match("/MSIEs+([^;)]+)+/i"$sys$ie);
             // $exp = $b[0]." (IE".$ie[1].")";
             $exp[0] = $b[0] . " (IE" $ie[1] . ")";
             $exp[1] = $ie[1];
         elseif (stripos($sys"MSIE") > 0) {
             preg_match("/MSIEs+([^;)]+)+/i"$sys$ie);
             //$exp = "Internet Explorer ".$ie[1];
             $exp[0] = "Internet Explorer";
             $exp[1] = $ie[1];
         elseif (stripos($sys"Netscape") > 0) {
             $exp[0] = "Netscape";
             $exp[1] = "";
         elseif (stripos($sys"Opera") > 0) {
             $exp[0] = "Opera";
             $exp[1] = "";
         elseif (stripos($sys"Chrome") > 0) {
             $exp[0] = "Chrome";
             $exp[1] = "";
         else {
             $exp "未知浏览器";
             $exp[1] = "";
         }
         return $exp;
     }
       
     //检测浏览器,如果为IE6及以下的,就跳转页面
     function check_browser(){
         $ie_array = getBrowser();
         if($ie_array[0]=='Internet Explorer' && $ie_array[1] <= 6){
             include './template/default/common/show_ie_out.htm';
             //header("Location: ./template/default/common/show_ie_out.htm");
             exit();
         }
     }
  • 相关阅读:
    常用的STL
    CString,string,char数组的转换
    linux知识
    十一种通用滤波算法(转)
    修复被勒索病毒cl0p损坏的svn代码
    android shell 转发代理shell示例
    3proxy配置
    windbg调试写dmp,随机名字
    nexus6p刷机注意
    mysql语句学习
  • 原文地址:https://www.cnblogs.com/roam/p/3792932.html
Copyright © 2011-2022 走看看