Recently, the customer asked the website to determine whether it was a mobile phone access or a computer access, and then display different information, so I found it online. this is not original and focuses on sharing. & Lt ;? PhpfunctionisMobile () {$ useragent = isset ($ _ SERVER [& amp; #39; HTTP_USER_AGENT & amp; #39;])...
Recently, the customer asked the website to determine whether it was a mobile phone access or a computer access, and then display different information, so I found it online. 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 ';
?>