最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
PHP验证终端类型是否为手机的简单实例
时间:2022-06-24 22:42:33 编辑:袖梨 来源:一聚教程网
代码如下 | 复制代码 |
/** * 判断当前访问的用户是 PC端 还是 手机端 返回true 为手机端 false 为PC 端 * @return boolean */ functionisMobile(){ $useragent=isset($_SERVER['HTTP_USER_AGENT']) ?$_SERVER['HTTP_USER_AGENT'] :''; //echo $useragent;die; $useragent_commentsblock=preg_match('|(.*?)|',$useragent,$matches)>0?$matches[0]:''; functionCheckSubstrs($substrs,$text){ foreach($substrsas$substr) if(false!==strpos($text,$substr)){ returntrue; } returnfalse; } $mobile_os_list=array('Google Wireless Transcoder','Windows CE','WindowsCE','Symbian','Android','armv6l','armv5','Mobile','CentOS','mowser','AvantGo','Opera Mobi','J2ME/MIDP','Smartphone','Go.Web','Palm','iPAQ'); $mobile_token_list=array('Profile/MIDP','Configuration/CLDC-','160×160','176×220','240×240','240×320','320×240','UP.Browser','UP.Link','SymbianOS','PalmOS','PocketPC','SonyEricsson','Nokia','BlackBerry','Vodafone','BenQ','Novarra-Vision','Iris','NetFront','HTC_','Xda_','SAMSUNG-SGH','Wapaka','DoCoMo','iPhone','iPod');
$found_mobile=CheckSubstrs($mobile_os_list,$useragent_commentsblock) || CheckSubstrs($mobile_token_list,$useragent);
if($found_mobile){ returntrue; }else{ returnfalse; } } |
相关文章
- 王者荣耀侦探能力大测试攻略 王者荣耀侦探能力大测试怎么过 11-22
- 无期迷途主线前瞻兑换码是什么 11-22
- 原神欧洛伦怎么培养 11-22
- 炉石传说网易云音乐联动怎么玩 11-22
- 永劫无间手游确幸转盘怎么样 11-22
- 无期迷途主线前瞻兑换码是什么 无期迷途主线前瞻直播兑换码介绍 11-22