PHP code example of yooer / useragent-parser
1. Go to this page and download the library: Download yooer/useragent-parser library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yooer / useragent-parser example snippets
serAgent\Parser;
// Get current user agent string
$userAgentString = $_SERVER['HTTP_USER_AGENT'];
// Parse the user agent
$ua = Parser::analyze($userAgentString);
// Get browser information
echo "Browser: " . $ua->browser['name'] . " " . $ua->browser['version'] . "\n";
// Get OS information
echo "OS: " . $ua->os['name'] . " " . $ua->os['version'] . "\n";
// Get device information
echo "Device: " . $ua->device['title'] . "\n";