PHP code example of silnik / browser

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

    

silnik / browser example snippets




    

$result = new Silnik/Browser(getallheaders());

$result = new Silnik/Browser($_SERVER['HTTP_USER_AGENT']);

"You are using " . $result->toString();
// You are using Chrome 27 on OS X Mountain Lion 10.8

$result->isType('desktop');
// true

$result->isType('mobile', 'tablet', 'media', 'gaming:portable');
// false

$result->isBrowser('Maxthon', '<', '4.0.5');
// false

$result->isOs('iOS', '>=', '8');
// false

$result->isOs('OS X');
// true

$result->isEngine('Blink');
// true

$result->browser->toString();
// Chrome 27  

$result->engine->toString();
// Blink

$result->os->toString();
// OS X Mountain Lion 10.8

$result->browser->name;
// Chrome

$result->browser->name . ' ' . $result->browser->version.toString();
// Chrome 27

$result->browser->version->value;
// 27.0.1453.110

$result->engine->name;
// Blink

$result->browser->version->is('>', 26);
// true

$result->os->version->is('<', '10.7.4');
// false

$result = new Silnik/Browser(getallheaders(), [ 'detectBots' => false ]);

$client = new \Memcached();
$client->addServer('localhost', 11211);

$pool = new \Cache\Adapter\Memcached\MemcachedCachePool($client);

$result = new Silnik/Browser(getallheaders(), [ 'cache' => $pool ]);

$client = new \Memcached();
$client->addServer('localhost', 11211);

$pool = new \Cache\Adapter\Memcached\MemcachedCachePool($client);

$result = new Silnik/Browser();
$result->setCache($pool);
$result->analyse(getallheaders());

$result->os->version->is('10.7.4');
// true

$result->os->version->is('10.7');
// true

$result->os->version->is('10');
// true

$result->os->version->is('10.0');
// false

$result->os->version->is('>', '10');
// false

$result->os->version->is('>', '10.7');
// false

$result->os->version->is('>', '10.7.3');
// true