The following small series will provide you with a simple example of php to determine whether mobile browser or web browser is used and perform the corresponding action. I think this is quite good. I will share it with you now and give you a reference. Let's take a look at it together. I have been searching for it on the Internet for a long time. let's record it.
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', 'cento', 'mogin', 'avantgo ', 'Opera mobi ', 'j2'/MIDP ', 'Smartphone', 'Go. web ', 'Palm', 'ipaq '); $ mobile_token_list = array ('Profile/MIDP', 'configuration/CLDC-', '2017 × 160 ', '000000', '000000', '000000', '000000', '000000', 'up. browser ', 'Up. link ', 'symbian OS', '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 '); // if it is a mobile phone, execute the Jump} else {header ('Location :. /web/index. php '); // if it is not on the mobile phone, execute the Jump}
The above php judges whether mobile browsing is web browsing, and executes a simple example of the corresponding action to share all the content with you. I hope to give you a reference, and I hope you can support your own home.