? PHP判斷PC端或移動端(Thinkphp3.2.3)-青島金屯化工有限公司

<sub id="pfv9x"></sub>

<form id="pfv9x"><meter id="pfv9x"><thead id="pfv9x"></thead></meter></form>

          <sub id="pfv9x"></sub>

              新聞咨詢

              移動端判斷函數:


              function.php頁面:

              <?php  

              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;    

                  }    

              }

              ?> 


              PC端頁面:


              // 判斷是否是手機端 ;是,跳轉到手機端網址

              if (isMobile()){

                  header('Location: http://wap.'.ltrim($_SERVER['HTTP_HOST'],'www.').$_SERVER['REQUEST_URI']);

              }


              手機端頁面:

              //判斷是否是PC端;是跳轉到電腦端網址

              if (!isMobile()){

                  header('Location: http://www.'.ltrim($_SERVER['HTTP_HOST'],'wap.').$_SERVER['REQUEST_URI']);

              }

              PHP判斷PC端或移動端(Thinkphp3.2.3)

              喜歡,請掃碼分享

              公司地址:青島膠州市李哥莊鎮大屯一村 

              電話:0532-88292835 E-Mail : 986503759@qq.com

              Copyright?2007-2008 青島金屯化工有限公司 All Rights Reserved.

              魯ICP備16050441號-1 | 安全生產許可證:(魯)WH安許證字(2014)020062號

              Whois查詢網站備案Thinkphp | LNMP |

              TOP

              金脉娱乐

              <sub id="pfv9x"></sub>

              <form id="pfv9x"><meter id="pfv9x"><thead id="pfv9x"></thead></meter></form>

                      <sub id="pfv9x"></sub>

                          <sub id="pfv9x"></sub>

                          <form id="pfv9x"><meter id="pfv9x"><thead id="pfv9x"></thead></meter></form>

                                  <sub id="pfv9x"></sub>