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

The constructor

PreviousHow to use (standalone)NextExample

Last updated 5 months ago

Was this helpful?

$detect = new MobileDetect(?CacheInterface $cache = null, array $config = [])

The constructor can receive an optional cache class compatible with

The constructor can also receive optional $config variables as follows:

Variable name
Default value
Description

autoInitOfHttpHeaders

true

Auto-initialization on HTTP headers from $_SERVER['HTTP...']. Disable this if you're going for performance and you want to manually set the User-Agent via $detect->setUserAgent(...)

maximumUserAgentLength

500

Maximum HTTP User-Agent value allowed.

cacheKeyFn

sha1

Method of encoding the cache key.

cacheTtl

86400

Default expiration date for the default Cache class implementation.

Psr\SimpleCache\CacheInterface