phpcms检测设备类型判断跳转PC还是手机链接

#phpcms中关于“ 设备类型的检测与判断 ”的设置 目的之一,就是便于: 让 phpcms 实现电脑,手机访问自动调用不同模板而URL地址不变! 也就是平时说的:“手机、电脑 双模板设置”。 ###总结...

#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);
}

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
admin
admin

651 篇文章

作家榜 »

  1. admin 651 文章
  2. 粪斗 185 文章
  3. 王凯 92 文章
  4. 廖雪 78 文章
  5. 牟雪峰 12 文章
  6. 李沁雪 9 文章
  7. 全易 2 文章
  8. Stevengring 0 文章