PHP判断电脑端还是手机端

生活原本沉闷 但跑起来就会有风

//判断手机端还是电脑端
function isMobile(){
   userAgent=isset(_SERVER['HTTP_USER_AGENT']) ? _SERVER['HTTP_USER_AGENT'] : '';userAgent_CommentsBlock=preg_match('|.∗?.∗?|',userAgent,matches)>0?matches[0]:'';
   function Check_subset(subsets,text){
       foreach(subsets as subset)
           if(false!==strpos(text,subset)){
               return true;
           }
       return false;
   }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','PocketP>C','SonyEricsson','Nokia','BlackBerry','Vodafone','BenQ','Novarra->Vision','Iris','NetFront','HTC_','Xda_','SAMSUNG-SGH','Wapaka','DoCoMo','iPhone','iPod');found_mobile=Check_Subset(mobile_os_list,userAgent_CommentsBlock) ||
       Check_Subset(mobile_token_list,userAgent);

   if ($found_mobile){
       return true;
   }else{
       return false;
   }
}
if (isMobile())
{
     include('./rw.html');
}else{
    include('./ej.html');

}

为您推荐

评论已关闭