[PHP] to Detect if browser is mobile

Use PHP to detect if browser is mobile


Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.

Download from the following link.
https://github.com/serbanghita/Mobile-Detect/tags

How to use in php code
require_once '../Mobile_Detect.php';
$detect = new Mobile_Detect;
if($detect->isMobile() ){
    // is mobile
}else if($detect->isTablet()){
    // is tablet
}else{
    // is computer
}
Source from: https://github.com/serbanghita/Mobile-Detect

留言

這個網誌中的熱門文章

How to PHP export to Excel 2

html viewport meta