PHP code example of udger / udger-php

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

    

udger / udger-php example snippets



$factory = new Udger\ParserFactory();
$parser = $factory->getParser();
$parser->setDataFile(sys_get_temp_dir() . "/udgercache/udgerdb_v3.dat");
//$parser->setCacheEnable(false);
//$parser->setCacheSize(4000);     
$parser->setUA('Mozilla/5.0 (Linux; Android 5.1.1; SAMSUNG SM-A510F Build/LMY47X) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/3.5 Chrome/38.0.2125.102 Mobile Safari/537.36');
$parser->setIP("2A02:598:7000:116:0:0:0:101");
$ret = $parser->parse();
echo "<pre>";
print_r($ret);
echo "</pre>";


Array
(
        [user_agent] => Array
        (
            [ua_string] => Mozilla/5.0 (Linux; Android 5.1.1; SAMSUNG SM-A510F Build/LMY47X) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/3.5 Chrome/38.0.2125.102 Mobile Safari/537.36
            [ua_class] => Mobile browser
            [ua_class_code] => mobile_browser
            [ua] => Mobile Samsung Browser 3.5
            [ua_version] => 3.5
            [ua_version_major] => 3
            [ua_uptodate_current_version] => 
            [ua_family] => Mobile Samsung Browser
            [ua_family_code] => mobile_samsung_browser
            [ua_family_homepage] => http://developer.samsung.com/internet
            [ua_family_vendor] => SAMSUNG
            [ua_family_vendor_code] => samsung
            [ua_family_vendor_homepage] => http://www.samsung.com/
            [ua_family_icon] => samsung_browser.png
            [ua_family_icon_big] => samsung_browser_big.png
            [ua_family_info_url] => https://udger.com/resources/ua-list/browser-detail?browser=Mobile Samsung Browser
            [ua_engine] => WebKit/Blink
            [os] => Android 5.1 lollipop
            [os_code] => android_5_1
            [os_homepage] => https://en.wikipedia.org/wiki/Android_Lollipop
            [os_icon] => android.png
            [os_icon_big] => android_big.png
            [os_info_url] => https://udger.com/resources/ua-list/os-detail?os=Android 5.1 lollipop
            [os_family] => Android
            [os_family_code] => android
            [os_family_vendor] => Google, Inc.
            [os_family_vendor_code] => google_inc
            [os_family_vendor_homepage] => https://www.google.com/about/company/
            [device_class] => Smartphone
            [device_class_code] => smartphone
            [device_class_icon] => phone.png
            [device_class_icon_big] => phone_big.png
            [device_class_info_url] => https://udger.com/resources/ua-list/device-detail?device=Smartphone
            [device_marketname] => Galaxy A5 (2016)
            [device_vendor] => Samsung
            [device_vendor_code] => samsung
            [device_vendor_homepage] => http://www.samsung.com/
            [device_vendor_icon] => samsung.png
            [crawler_last_seen] => 
            [crawler_category] => 
            [crawler_category_code] => 
            [crawler_respect_robotstxt] => 
        )

    [ip_address] => Array
        (
            [ip] => 2A02:598:7000:116:0:0:0:101
            [ip_ver] => 6
            [ip_classification] => Crawler
            [ip_classification_code] => crawler
            [ip_hostname] => 
            [ip_last_seen] => 2016-02-12 04:28:56
            [ip_country] => Czech Republic
            [ip_country_code] => CZ
            [ip_city] => Prague
            [crawler_name] => SeznamBot/3.2-test1
            [crawler_ver] => 3.2-test1
            [crawler_ver_major] => 3
            [crawler_family] => SeznamBot
            [crawler_family_code] => seznambot
            [crawler_family_homepage] => http://napoveda.seznam.cz/cz/seznambot.html
            [crawler_family_vendor] => Seznam.cz, a.s.
            [crawler_family_vendor_code] => seznam-cz_as
            [crawler_family_vendor_homepage] => http://www.seznam.cz/
            [crawler_family_icon] => seznam.png
            [crawler_family_info_url] => https://udger.com/resources/ua-list/bot-detail?bot=SeznamBot#id12590
            [crawler_last_seen] => 2016-02-15 06:12:28
            [crawler_category] => Search engine bot
            [crawler_category_code] => search_engine_bot
            [crawler_respect_robotstxt] => unknown
            [datacenter_name] => 
            [datacenter_name_code] => 
            [datacenter_homepage] => 
        )

)