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