Any php code to detect the browser with version and operating system?

后端 未结 4 2092
面向向阳花
面向向阳花 2020-12-03 12:13

I tried to search in google but cannot find a complete solution (i only find something detects only the browser\'s type like firefox, opera) .

i want a php class or

4条回答
  •  庸人自扰
    2020-12-03 13:02

    I used the techpatterns.com one and they don't always update it and it use procedural code which feel dated...

    The Wolfcast BrowserDetection PHP class is updated and use an Object-Oriented way to do it:

    You use it this way:

    $browser = new BrowserDetection();
    echo 'You are using ', $browser->getBrowser(), ' version ', $browser->getVersion();
    

    Another example:

    $browser = new BrowserDetection();
    if ($browser->getBrowser() == BrowserDetection::BROWSER_FIREFOX && $browser->compareVersions($browser->getVersion(), '5.0.1') !== 1) {
        echo 'You have FireFox version 5.0.1 or greater. ';
    }
    

提交回复
热议问题