guiliredu / simple-user-agent
A package to get info from a user agent
Installs: 1 003
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 3
Forks: 3
Open Issues: 0
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2024-10-28 06:01:46 UTC
README
A simple class to parse data from a user agent.
<?php require __DIR__ . '/vendor/autoload.php'; use SimpleUserAgent\UserAgent; $agent = new UserAgent();
You can set a user agent in the first parameter of the constructor. If the parameter is empty, it will try to parse data from $_SERVER['HTTP_USER_AGENT']
$agent = new UserAgent('Mozilla/5.0 ...');
You can set a user agent after instantiation, calling this method:
$agent->setAgent('Mozilla/5.0 ...');
To get the data, you can call these available methods
$agent->getAgent() // Full user agent string $agent->getDevice() // iPhone $agent->getOS() // iOS $agent->getBrowser() // Apple Safari $agent->getPrefix() // Safari $agent->getVersion() // 11.0 $agent->getEngine() // WebKit $agent->isBot() // true / false $agent->getInfo() // Array with all the above info
This project is under development - For test purposes only
References: