Wolfcast BrowserDetection PHP class

Project page on GitHub

Live demo (version 2.9.7)

You are using Safari unknown to view this page.

User agent: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Browser name: Safari
Browser version: unknown
Platform family: unknown
Platform version: unknown
Platform version name: unknown
Platform is 64-bit: No
Is mobile: No
Is robot: No
Robot name: Not applicable
Robot version: Not applicable
IE is in compatibility view: No
Emulated IE version: Not applicable
Is Chrome Frame: No

Documentation

You can find the complete documentation for the Wolfcast BrowserDetection PHP class on the previous link.

Quick PHP tutorial

require_once('BrowserDetection.php');

$browser = new Wolfcast\BrowserDetection();

//Add support for a "custom" Web browser on the fly:
$browser->addCustomBrowserDetection('Vivaldi');

$userAgent       = $browser->getUserAgent();               //string
$browserName     = $browser->getName();                    //string
$browserVer      = $browser->getVersion();                 //string
$platformFamily  = $browser->getPlatform();                //string
$platformVer     = $browser->getPlatformVersion(true);     //string
$platformName    = $browser->getPlatformVersion();         //string
$platformIs64bit = $browser->is64bitPlatform();            //boolean
$isMobile        = $browser->isMobile();                   //boolean
$isRobot         = $browser->isRobot();                    //boolean
$isInIECompat    = $browser->isInIECompatibilityView();    //boolean
$strEmulatedIE   = $browser->getIECompatibilityView();     //string
$arrayEmulatedIE = $browser->getIECompatibilityView(true); //array('browser' => '', 'version' => '')
$isChromeFrame   = $browser->isChromeFrame();              //boolean

//Test if the user uses Microsoft Edge
if ($browser->getName() == Wolfcast\BrowserDetection::BROWSER_EDGE) {
    echo 'You are using Edge!';
}

//Test if the user uses specific versions of Internet Explorer
if ($browser->getName() == Wolfcast\BrowserDetection::BROWSER_IE) {
    //As you can see you can compare major and minor versions under a string format '#.#.#' (no limit in depth)
    if ($browser->compareVersions($browser->getVersion(), '11.0.0.0') < 0) {
        echo 'You are using IE < 11.';
    }

    if ($browser->compareVersions($browser->getVersion(), '11.0.0') == 0) {
        echo 'You are using IE 11.';
    }

    if ($browser->compareVersions($browser->getVersion(), '11.0') > 0) {
        echo 'You are using IE > 11.';
    }

    if ($browser->compareVersions($browser->getVersion(), '11') >= 0) {
        echo 'You are using IE 11 or greater.';
    }
}

//Test a new user agent and output the instance of BrowserDetection as a string
$browser->setUserAgent('Mozilla/5.0 (Windows NT 6.3; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0');
echo $browser;