Skip to content

Commit

Permalink
Added additional explanation
Browse files Browse the repository at this point in the history
See #948
  • Loading branch information
serbanghita committed Nov 7, 2023
1 parent b73a5bd commit 90416e0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion scripts/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,27 @@
require_once __DIR__ . '/../vendor/autoload.php';

$detect = new MobileDetect();
// This is optional. We scan for known $_SERVER variables.
// See: https://github.com/serbanghita/Mobile-Detect/issues/948#issuecomment-1800271108
$detect->setUserAgent('Mozilla/5.0 (iPad; CPU OS 14_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) GSA/248.1.504392274 Mobile/15E148 Safari/604.1');

$isMobile = false;
try {
$isMobile = $detect->isMobile();
var_dump($isMobile);

} catch (\Detection\Exception\MobileDetectException $e) {
}

var_dump($isMobile);

$isTablet = false;
try {
$isTablet = $detect->isTablet();
var_dump($isTablet);
} catch (\Detection\Exception\MobileDetectException $e) {
}

var_dump($isTablet);



0 comments on commit 90416e0

Please sign in to comment.