Example one (recommended):
<?PHPHeader("Content-type:text/html;charset=utf-8");functionIsMobile () {$useragent=isset($_server[' Http_user_agent ']) ?$_server[' Http_user_agent ']: '; $useragent _commentsblock=Preg_match(' |\ (. *?\) | ',$useragent,$matches) >0?$matches[0]: '; functionChecksubstrs ($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 ', ' CentOS ', ' Mowser ', ' AvantGo ', ' Opera Mobi ', ' J2ME/MIDP ', ' Smartphone ', ' go.web ', ' Palm ', ' IPAQ '); $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 '); $found _mobile=checksubstrs ($mobile _os_list,$useragent _commentsblock) ||Checksubstrs ($mobile _token_list,$useragent); if($found _mobile){ return true; }Else{ return false; } }if(IsMobile ())Echo' Mobile login ';Else Echo' Computer Login ';?>
Example two:
<?PHPHeader("Content-type:text/html;charset=utf-8");$agent=Check_wap ();if($agent ) Echo' Mobile login ';Else Echo' Computer Login ';//Check if WAPfunctionCheck_wap () {//first check whether it is a WAP proxy, high accuracy if(@Stristr($_server[' Http_via '], "WAP")){ return true; } //Check if the browser accepts WML. ElseIf(Strpos(Strtoupper($_server[' http_accept ']), "VND. Wap. WML ") > 0){ return true; } //Check User_agent ElseIf(Preg_match('/(blackberry|configuration\/cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera Mini|opera | googlebot-mobile| yahooseeker\/m1a1-r2d2|android|iphone|ipod|mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh| Spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/I ',$_server[' Http_user_agent '])){ return true; } Else{ return false; }}?>
Reference Address: http://www.jb51.net/article/45951.htm
Http://www.jb51.net/article/42664.htm
PHP to determine the phone access or computer access sample sharing