Just need, on the internet for a long time, record
1 function IsMobile () {2 $useragent =isset ($_server[' http_user_agent '))? $_server[' Http_user_agent ']: '; 3 $useragent _commentsblock=preg_match (' |\ (. *?\) | ', $useragent, $matches) >0? $matches [0]: '; 4 function Checksubstrs ($substrs, $text) {5 foreach ($substrs as $SUBSTR) 6 if (False!==strpos ($t Ext, $substr)) {7 return true; 8} 9 return false; Ten}11 $mobile _os_list=array (' Google Wireless transcoder ', ' Windows CE ', ' windowsce ', ' Symbian ', ' Android ', ' armv6l ', ' a Rmv5 ', ' Mobile ', ' CentOS ', ' mowser ', ' AvantGo ', ' Opera Mobi ', ' J2ME/MIDP ', ' Smartphone ', ' go.web ', ' Palm ', ' IPAQ '); 12 $ Mobile_token_list=array (' PROFILE/MIDP ', ' configuration/cldc-', ' 160x160 ', ' 176x220 ', ' 240x240 ', ' 240x320 ', ' the ' , ' Up. Browser ', ' up. Link ', ' SymbianOS ', ' PalmOS ', ' PocketPC ', ' SonyEricsson ', ' Nokia ', ' BlackBerry ', ' Vodafone ', ' BenQ ', ' novarra-vision ', ' Iris ', ' NetFront ', ' htc_ ', ' Xda_ ', ' samsung-sgh ', ' Wapaka ', ' DoCoMo ', ' iPhone ', ' iPod '; 13 $found _mobile=checksubstrs ($mobile _os_list, $useragent _commentsblock) | | Checksubstrs ($mobile _token_list, $useragent); if ($found _mobile) {+-return true; }else{return false; +}23 if (IsMobile ()) {(' Location:./app/index.php ');//If it is the mobile side, perform jump}26 else{27 header (' Locati On:./web/index.php ');//If non-Mobile, execute jump 28}
PHP to determine whether mobile browsing or web browsing, and perform the corresponding action