欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php判斷手機(jī)瀏覽還是web瀏覽,并執(zhí)行相應(yīng)的動(dòng)作簡(jiǎn)單實(shí)例

 更新時(shí)間:2016年07月28日 09:54:13   投稿:jingxian  
下面小編就為大家?guī)硪黄猵hp判斷手機(jī)瀏覽還是web瀏覽,并執(zhí)行相應(yīng)的動(dòng)作簡(jiǎn)單實(shí)例。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給的大家做個(gè)參考。一起跟隨小編過來看看吧

正好需要,在網(wǎng)上找了好久,記錄一下

function isMobile(){ 
  $useragent=isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; 
  $useragent_commentsblock=preg_match('|\(.*?\)|',$useragent,$matches)>0?$matches[0]:'';    
  function CheckSubstrs($substrs,$text){ 
    foreach($substrs as $substr) 
      if(false!==strpos($text,$substr)){ 
        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','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){ 
    return true; 
  }else{ 
    return false; 
  } 
}
if (isMobile()){
  header('location: ./app/index.php');//如果為手機(jī)端,執(zhí)行跳轉(zhuǎn)
}
else{
  header('location: ./web/index.php');//如果非手機(jī)端,執(zhí)行跳轉(zhuǎn)
}

以上這篇php判斷手機(jī)瀏覽還是web瀏覽,并執(zhí)行相應(yīng)的動(dòng)作簡(jiǎn)單實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論