Mobile_Detect is a lightweight open source mobile device (mobile phone) detection PHP Class,
It uses the string in User-Agent, combined with HTTP Header, to detect the mobile device environment.
The most powerful thing about this device detection PHP class library is that it has a very complete library,
Can detect the device type used (including operation type, mobile phone brand, etc.) and browser details.
The complete Mobile_Detect code is as follows:
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)