PHP code example of gemz / useragent

1. Go to this page and download the library: Download gemz/useragent 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/ */

    

gemz / useragent example snippets

 php
use Gemz\Useragent;

// static instantiation
$parser = Useragent::agent($string);

// object instantiation
$parser = new Useragent($string);

// Get Result
$result = $parser->result(); // returns array

[
    'isBot' => false, 
    'browserType' => 'browser',
    'browserEngine' => 'Blink',
    'browserName' => 'Chrome',
    'browserVersion' => '79.0',
    'device' => 'desktop',
    'deviceModel' => '',
    'deviceBrand' => '', 
    'os' => 'Mac',
    'isMobile' => false,
]

// Set a new useragent
$result = $parser
    ->for($string)
    ->result();
    
// If you need full access to the piwik device detector instance 
$detector = $parser->parser(); // returns DeviceDetector\DeviceDetector;
$detector->...