Home >Backend Development >PHP Tutorial >PHP class library for detecting mobile devices (cell phones)
Mobile_Detect
//使用实例 include 'Mobile_Detect.php'; $detect = new Mobile_Detect(); // Check for any mobile device. if ($detect->isMobile()) // Check for any tablet. if($detect->isTablet()) // Check for any mobile device, excluding tablets. if ($detect->isMobile() && !$detect->isTablet()) if ($detect->isMobile() && !$detect->isTablet()) // Alternative to $detect->isAndroidOS() $detect->is('AndroidOS'); // Batch usage foreach($userAgents as $userAgent){ $detect->setUserAgent($userAgent); $isMobile = $detect->isMobile(); } // Version check. $detect->version('iPad'); // 4.3 (float)
Source: http://www.oschina.net/code/snippet_118180_16788
The above introduces the PHP class library for detecting mobile devices (mobile phones), including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.