Now through the mobile phone access to the site is increasingly popular, if we want to count the site through the PC, mobile phone mobile end of the situation, or the need for mobile phone to do some special processing, then we need to visit the users of the site to do the identification of the client, The following example is a way of using PHP to identify whether a user is a computer or a mobile phone.
<?php function IsMobile () {$useragent =isset ($_server[' http_user_agent '])? $_server[' Http_user_agent ']: ';
$useragent _commentsblock=preg_match (' (. *?\) ', $useragent, $matches) >0? $matches [0]: '; $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-', ' 160x160 ', ' 176x220 ', ' 240x240 ', ' 240x320 ', ' 320x 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 '; $found _mobile=checksubstrs ($mobile _os_list, $useragent _commentsblock) checksubstrs ($mobile _token_list, $useragent
);
if ($found _mobile) {return true;
}else{return false; } function Checksubstrs ($substrs, $text) {foreach ($substrs as $substr) {if (false!==strpos ($text, $substr)) {return true;
return false; } if (IsMobile ()) {echo ' mobile login m.alixixi.com ';}
else{echo ' computer login www.Alixixi.com '; }
Articles that you may be interested in
- Use. htaccess to deny an IP access site
- PHP access to the client computer screen width, height, resolution method
- PHP calculates a function that is currently in the first week of a year or January
- The method of PHP asynchronous debugging and online debugging Web site program
- How PHP Gets the start time stamp and end time stamp for today, yesterday, last week, month
- Good User Experience website homepage design must know 12 points
- How the page should load JavaScript to improve site performance
- PHP Statistics search engine access record