PHP: how to identify websites accessed by a computer or mobile phone _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
How PHP identifies websites accessed by computers or mobile phones. How does PHP identify websites accessed by computers or mobile phones? it is becoming increasingly popular to visit websites through mobile phones. if we want to count the number of websites accessed through PCs, how does PHP identify visits to websites on mobile phones?

Access to websites through mobile phones is becoming more and more popular. if we want to count the traffic of websites through PCs and mobile terminals, or we need to do some special processing for mobile terminals, then we need to identify the client of the user accessing the website. The following example uses php to identify whether the user accesses the website through a computer or a mobile phone.

 0? $ Matches [0]: ''; $ mobile_ OS _list = array ('Google Wireless Transcoder ', 'windows CE', 'windowsce ', 'symbian', 'Android ', 'armv6l', 'armv5 ', 'mobile', 'cento', 'moyun', 'avantgo', 'Opera mobi', 'j2', 'Smartphone ', 'Go. web ', 'Palm', 'ipaq '); $ mobile_token_list = array ('Profile/MIDP', 'configuration/CLDC-', '2017 × 160 ', '000000', '000000', '000000', '000000', '000000', 'up. browser ', 'Up. link ', 'symbian OS', 'palmos ', 'pocketpc', 'sonyer Icsson ', '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 'log on to m.phpernote.com ';} else {echo 'computer logon www.phpernote.com ';}
Articles you may be interested in
  • Using. htaccess to deny access to a website from an ip address
  • Php calculates the number of weeks in a year or January.
  • Php obtains the screen width, height, and resolution of the client computer.
  • Php asynchronous debugging and online debugging of website programs
  • Php obtains the start and end timestamps of today, yesterday, last week, and this month.
  • 12 points are required for the design of a website homepage with good user experience
  • The last record of the volist loop in the thinkphp Template
  • Js address bar special effects (display the size of all images with links on the page and view the height of the current browser)

Vivo is now becoming more and more popular in accessing websites through mobile phones. if we want to count the website's access volume through PCs and mobile terminals...

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.