Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of judging whether it is a mobile phone or not by phpcms

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the method of phpcms to judge whether it is a mobile phone, which has a certain reference value and can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

Phpcms determines whether it is a mobile phone.

Create an isMobile () method to determine whether the user is accessing from a mobile phone.

/ * Function isMobile * @ param $n judge mobile version * / 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 (falsehoods infected 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-','160 × 160 paramedics, 240x240, 240x240, 320pyrs, 320x3x240, 320x3x240, 320x3x240, 320x3x240, 320x240, 200x320, 320x240, 350x320, 320, 320,320, 320,320, 320,320, 320,320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 240, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 240, 320, 240, 320, 240, 320, 320, 240, 320, 240, 320, 240, 320, 240, 320, 240, 320, 240, 320, 240, 320, 240, 320, 240, 320, 240, 320, 240, 320, 240, 240, 240, 240, 240, 240, 240, 240, 320, 240, 320, 240, 320, 240, 'iPod') $found_mobile=CheckSubstrs ($mobile_os_list,$useragent_commentsblock) | | CheckSubstrs ($mobile_token_list,$useragent); if ($found_mobile) {return true;} else {return false }} Thank you for reading this article carefully. I hope it will be helpful for everyone to share the method of phpcms to judge whether it is a mobile phone or not. At the same time, I also hope that you will support it, pay attention to the industry information channel, and find out if you have any problems. Detailed solutions are waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report