MobileDetect PHP
Github4.8.x3.74.x2.8.xDemo
  • Introduction
  • Install
  • How to use (composer)
  • How to use (standalone)
  • The constructor
  • Example
  • Other versions
  • Demo
  • Performance
  • Contribute
  • Developing code
  • Project structure
  • Extending / Porting
  • Add new module, plugin or port
  • Plugins, Modules and Ports
  • Credits
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub

How to use (standalone)

Learn how to use Mobile Detect library as a standalone PHP class, without composer.

PreviousHow to use (composer)NextThe constructor

Last updated 5 months ago

Was this helpful?

git clone git@github.com:serbanghita/Mobile-Detect.git
git checkout 4.8.x

Or without git, just go to and click on the green button "Code" -> "Download ZIP" (by default you get 4.8.x version).

<?php
// example.php contents

use Detection\Exception\MobileDetectException;
use Detection\MobileDetectStandalone;

require_once './Mobile-Detect/standalone/autoloader.php';
require_once './Mobile-Detect/src/MobileDetectStandalone.php';

$detection = new MobileDetectStandalone();
$detection->setUserAgent('iPad');

try {
    var_dump($detection);
    var_dump($detection->isMobile());
} catch (MobileDetectException $e) {
    print_r($e);
}

https://github.com/serbanghita/Mobile-Detect