HTTP User Agent Detector
dAgent
is a simple PHP class to detect HTTP User Agents by Device Type
, Brand
, Browser
, Operating System
and CPU Architecture
.
dAgent
is a standard php class which detects information from HTTP User Agent:
require_once './class/dAgent.php'; // Import dAgent class file where ever it is
$dAgent = new dAgent(); // Construct to a new variable
var_dump($dAgent->data); // Show the results
returns an php object with the following properties:
$dAgent = new dAgent();
$dAgent->data->type; // Returns string of device type 'Phone', 'Tablet', 'Desktop' or utility types such as 'Bot', 'TV', 'Console', etc.
$dAgent->data->brand; // Returns phone or tablet brand if available, otherwise 'null'
$dAgent->data->browser; // Returns the browser name if available, otherwise 'null'
$dAgent->data->os; // Returns the operating system name if available, otherwise 'null'
$dAgent->data->arch; // Returns the cpu architecture if available, otherwise 'null'
returns true
if the user agent is a kind of Smart Phone
, otherwise returns false
.
$dAgent = new dAgent();
if ($dAgent->isPhone) echo 'This device is a smart phone';
returns true
if the user agent is a kind of Tablet
, otherwise returns false
.
$dAgent = new dAgent();
if ($dAgent->isTablet) echo 'This device is a tablet';
returns true
if the user agent is a kind of Standard Computer
, otherwise returns false
.
$dAgent = new dAgent();
if ($dAgent->isDesktop) echo 'This device is a desktop computer';
returns true
if the user agent is a kind of utility including Search Engine Bots
, Smart TVs
, Game Consoles
and Smart Watches
, otherwise returns false
.
$dAgent = new dAgent();
if ($dAgent->isUtility) echo 'This device is an online utility';