PHP How to identify a computer or mobile phone to visit the website _php tutorial

Source: Internet
Author: User

How PHP identifies a computer or mobile phone to visit a website


Now through the mobile phone access to the site more and more popular, if we want to count the website through the PC, mobile phone mobile side of the situation, or need to do some special processing mobile phone, then we need to visit the site of the user's client to do the identification, The following example is a way to identify whether a user is a computer or a mobile phone through PHP.

 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 ', ' "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.phpernote.com ';} Else{echo ' computer login www.phpernote.com ';}

Articles you may be interested in

    • Use. htaccess to deny an IP access to a Web site
    • PHP calculates a function that is currently the first week of the year or January
    • PHP Gets the client computer screen width, height, resolution method
    • PHP asynchronous debugging and online debugging methods for Web programs
    • PHP gets the start timestamp and end timestamp for today, yesterday, last week, this month
    • A good User Experience site home page design must know 12 points
    • The last record in the thinkphp template that determines the volist loop
    • JS Address bar effect (displays the size of all linked images within the page and the height of the current browser)

http://www.bkjia.com/PHPjc/882412.html www.bkjia.com true http://www.bkjia.com/PHPjc/882412.html techarticle PHP How to identify is a computer or mobile phone access to the site now through mobile phone access to the site is becoming more and more popular, if we want to count the website through the PC, mobile phone mobile side of the respective traffic situation ...

  • 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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.