What is the best PHP detect mobile class? #detect mobile
Edit
by Mark Hoggan - 9 years ago (2015-12-18)
Detect Mobile Browser
| I need a class to detect if the user is using a browser from a mobile device. |
Ask clarification
3 Recommendations
PHP Mobile Detect: Detect whether the user is using a mobile device
This class can detect whether the user is using a mobile device.
It can check the browser user agent identification and determine if it is one of the known mobile devices.
Currently it can detect devices using Android, IOS, Blackberry, Opera, Palm, Windows Phone or something other generic mobile system.
| by Mega sploder 180 - 9 years ago (2016-02-18) Comment
Detect whether the user is using a mobile device |
This class can detect the type of mobile device checking headers.
It can check the HTTP request user agent and other request headers and detect the type of mobile device if the request comes from a user with a mobile browser.
The class looks up at an internal list of user agent strings known to be of mobile devices and returns information of whether the device is mobile or not, or is a phone or tablet, get the operating system.
| by Haseeb Ahmad Basil package author 505 - 9 years ago (2016-02-16) Comment
A Lightweight Mobile Detecting Script |
This class can parse the user agent and extract browser details.
It can parse the current browser user agent or a given user agent string.
The class can analyze the user agent details and store detected browser characteristics in class variables.
Currently it can detect the browser type, computer type (PC, mobile, bot), computer OS, and technology capabilities like JavaScript, frames, CSS, VBScript, cookies, background sounds, Java, ActiveX, mobile, etc..
| by Manuel Lemos 26695 - 9 years ago (2015-12-23) Comment
There are a few classes for this purpose. This one has been updated recently and can detect other browser capabilities besides detecting whether it is being run on a mobile device or not. |
- 1 Comment
1.
by Mike Siers - 9 years ago (2015-12-23) Reply
download the zip file from mobiledetect.net above and here is the code to detect the type of device.
include_once $_SERVER['DOCUMENT_ROOT'] . '/detect/Mobile_Detect.php';
function deviceType()
{
$detect = new Mobile_Detect;
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
$_SESSION['DeviceType']=$deviceType;
return $deviceType;
}