phpcms中关于设备类型的检测与判断的设置

phpcms中关于“ 设备类型的检测与判断 ” 的设置

目的之一,就是便于: 让 phpcms 实现电脑,手机访问自动调用不同模板而URL地址不变!
也就是平时说的:“手机、电脑 双模板设置”


总结提取的判断代码如下:

/*判断客户端*/
        if(substr($_SERVER['SERVER_NAME'], 0,1) == 'm'){
            include template('content_m','index',$default_style);
        }elseif(stristr($_SERVER['HTTP_VIA'],"wap")){// 先检查是否为wap代理,准确度高
            include template('content_m','index',$default_style);
        }elseif(strpos(strtoupper($_SERVER['HTTP_ACCEPT']),"VND.WAP.WML") > 0){// 检查浏览器是否接受 WML.
            include template('content_m','index',$default_style);
        }elseif(preg_match('/(blackberry|configuration\/cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera mini|opera |Googlebot-Mobile|YahooSeeker\/M1A1-R2D2|android|iphone|ipod|mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh|spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/i', $_SERVER['HTTP_USER_AGENT'])){//检查USER_AGENT
            include template('content_m','index',$default_style);  
        }else{
            include template('content','index',$default_style);
        }

具体的修改步骤,点击查看:phpcms 怎样实现电脑,手机访问自动调用不同模板而URL地址不变?


以上就是关于“ phpcms中关于“ 设备类型的检测与判断 ” 的设置 ” 的全部内容。

猜你喜欢

转载自blog.csdn.net/qq_35393869/article/details/80761440