zoukankan      html  css  js  c++  java
  • discuz php判断是手机访问还是电脑访问网站

    首先在模块处填入代码:

    //手机网页跳转
    //如果检测到访问的浏览器为下列一个指定的移动浏览器 则返回true
    function is_mobile(){
        $regex_match="/(nokia|iphone|android|motorola|^mot-|softbank|foma|docomo|kddi|up.browser|up.link|";
        $regex_match.="htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|";
        $regex_match.="blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|";   
        $regex_match.="symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte-|longcos|pantech|gionee|^sie-|portalmmm|";
        $regex_match.="jigs browser|hiptop|^ucweb|^benq|haier|^lct|operas*mobi|opera*mini|320x320|240x320|176x220";
        $regex_match.=")/i";       
        return isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE']) or preg_match($regex_match, strtolower($_SERVER['HTTP_USER_AGENT']));
    }

    然后是模板调用,调用代码:

    <!--{eval $is_mobile = is_mobile();}-->
    
    <!--{if $is_mobile}-->
    
    <!-- 显示此内容表示手机来路,让网站显示适合手机的内容 -->
    当然这里也可以用
    <!--{eval header("Location: http://www.juhutang.com/ ?手机版.html");}-->
    
    <!--{else}-->
    
    <!-- 显示此内容表示电脑来路,让网站显示适合电脑浏览的内容 -->
    <!--{eval header("Location: http://www.juhutang.com/ ?电脑版.html");}-->
    
    <!--{/if}-->

    也可以跳转,也可以显示内容,具体的随意了。

  • 相关阅读:
    RS232串口通信详解
    VS2010 常用的快捷键
    Qt .pro文件详解
    Qt 编译出现 error LNK2019: 无法解析的外部符号
    LabVIEW部分视觉函数中文解说
    NI Vision 介绍
    LabVIEW的优点
    VisionPro和Halcon的详细对比
    康耐视软件VisionPro-max-u与VisionPro-plus-u的区别
    TensorFlow 介绍
  • 原文地址:https://www.cnblogs.com/php411161555/p/3877936.html
Copyright © 2011-2022 走看看