Provides various official and user-released code examples. For code reference, you are welcome to exchange and learn more recently. The customer asks the website to determine whether it is a mobile phone access or a computer access, and then display different information, so I found it on the Internet. This is not original and focuses on sharing.
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', 'moyun', 'avantgo ', 'Opera Mobi', 'j2's/MIDP ', 'smartphone', 'go. web ', 'palm', 'ipaq ');
$ Mobile_token_list = array ('profile/MIDP ', 'configuration/CLDC-', '000000', '000000', '000000', '000000 ', '1970*240 ', '1970*320', '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 ())
Echo 'Log On To m.php100.com on the mobile phone ';
Else
Echo 'Log On To www.php100.com on your computer ';
?>
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB