是否有任何PHP代码可检测具有版本和操作系统的浏览器? [英] Any php code to detect the browser with version and operating system?
问题描述
我试图在google中搜索,但找不到完整的解决方案(我只发现某些东西只能检测到浏览器的类型,例如firefox,opera).
我想要一个php类或代码来检查用户的浏览器,包括版本以及操作系统.
谢谢
我使用了 techpatterns.com 一个,但他们并不总是更新它,而是使用感觉过时的程序代码...
Wolfcast BrowserDetection PHP类已更新,并使用面向对象的方式进行:>
您以这种方式使用它:
$browser = new BrowserDetection();
echo 'You are using ', $browser->getBrowser(), ' version ', $browser->getVersion();
另一个例子:
$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. ';
}
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 code to check the user's Browser including the version and also the operating system.
Thanks
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. ';
}
这篇关于是否有任何PHP代码可检测具有版本和操作系统的浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!