talira

Mobile Detect

PHP class for detecting mobile devices and tablets

open sourceMITfree

Mobile Detect is a lightweight PHP class that detects mobile devices, tablets included, from the User-Agent string combined with specific HTTP headers. It's installed with Composer as mobiledetect/mobiledetectlib. Version 4.8.x is the main line, updated first, and needs PHP 8.0 or newer; 3.74.x is a long-term support line for PHP 7.4, and 2.8.x is deprecated.

Problems it solves

  • tell whether a visitor is on a phone or a tablet in my PHP app
  • serve a different layout to mobile visitors from the server side in PHP
  • detect tablets separately from phones from the user agent

Features

  • detects mobile phones and tablets
  • uses the User-Agent string plus specific HTTP headers
  • online demo at demo.mobiledetect.net