PHP to judge the phone access or computer access sample sharing

Source: Internet
Author: User

  This article mainly introduces the website judgment is the mobile phone access or the computer access, then displays the different information, everybody references uses the bar

The code is as follows: <?php 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;      }     &nbs P;return false;   &NBSP   $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 ', ' 320x240 ', ' 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;   &NBSP}  } if (IsMobile ())  echo ' mobile login m.jb51.com '; else  echo ' computer login www.jb51.com ';?>  
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.