新的is_mobile()函数判断Emlog手机移动设备

em_is_mobile()函数

这个就把所有的移动设备比较全的展现出来了!

function em_is_mobile() {
 $user_agent = $_SERVER[’HTTP_USER_AGENT’];
 $mobile_browser = Array(
 "mqqbrowser", //手机QQ浏览器
 "opera mobi", //手机opera
 "juc","iuc",//uc浏览器
 "fennec","ios","applewebKit/420","applewebkit/525","applewebkit/532","ipad","iphone","ipaq","ipod",
 "iemobile", "windows ce",//windows phone
 "240x320","480x640","acer","android","anywhereyougo.com","asus","audio","blackberry","blazer","coolpad" ,"dopod", "etouch", "hitachi","htc","huawei", "jbrowser", "lenovo","lg","lg-","lge-","lge", "mobi","moto","nokia","phone","samsung","sony","symbian","tablet","tianyu","wap","xda","xde","zte"
 );
 $is_mobile = false;
 foreach ($mobile_browser as $device) {
 if (stristr($user_agent, $device)) {
 $is_mobile = true;
 break;
 }
 }
 return $is_mobile;
}

函数的调用方法也很简单:

<?php if (em_is_mobile() ): ?> //这里写你要实现的代码 <?php endif ;?>

您可以选择一种方式赞助本站

目前评论:1   其中:访客  1   博主  0

  1. 2010年10月01日 12:52  沙发
评论加载中...

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: