<?php
require_once dirname(__FILE__) . '/Mobile-Detect/src/MobileDetect.php';

$detect = new \Detection\MobileDetect;

$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
    
if($deviceType == 'tablet') {
    $patterns = $detect::getTabletDevices();
} elseif($deviceType == 'phone') {
    $patterns = $detect::getPhoneDevices();
    
} elseif($deviceType == 'computer') {
    $patterns = "";
    $model = "PC";
}

if($patterns) {
    foreach ($patterns as $brand => $pattern) {
        if (preg_match('/' . $pattern . '/i', $_SERVER['HTTP_USER_AGENT'], $matches)) {
            $model = $brand . ' ' . $matches[1];
            break;
        }
    }
}

echo $model;