我尝试了一些解决方案,但我无法获得确切的名称和版本:
I have tried some solutions but I am unable to get exact name and version:
我正在尝试以下代码:
$browserAgent = $_SERVER['HTTP_USER_AGENT'];
echo $browserAgent;
以上代码的输出:
Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24
但我正在使用:
Google Chrome 11.0.696.68
on
Ubuntu 10.04
所以我可以在输出字符串中的 Chrome/11.0.696.68
中找到,但它还显示了一些其他浏览器名称,这些名称令人困惑,无法从中提取确切的浏览器 名称/版本字符串.
So I can find in Chrome/11.0.696.68
in output string but it is also showing some other browsers names that is confusing to extract exact browser name/version from string.
使用 get_browser()
来自手册:
echo $_SERVER['HTTP_USER_AGENT'] . "
";
$browser = get_browser(null, true);
print_r($browser);
将返回:
Array
(
[browser_name_regex] => ^mozilla/5.0 (windows; .; windows nt 5.1; .*rv:.*) gecko/.* firefox/0.9.*$
[browser_name_pattern] => Mozilla/5.0 (Windows; ?; Windows NT 5.1; *rv:*) Gecko/* Firefox/0.9*/
[parent] => Firefox 0.9
[platform] => WinXP
[browser] => Firefox
[version] => 0.9
[majorver] => 0
[minorver] => 9
[cssversion] => 2
[frames] => 1
[iframes] => 1
[tables] => 1
[cookies] => 1
[backgroundsounds] =>
[vbscript] =>
[javascript] => 1
[javaapplets] => 1
[activexcontrols] =>
[cdf] =>
[aol] =>
[beta] => 1
[win16] =>
[crawler] =>
[stripper] =>
[wap] =>
[netclr] =>
)
这篇关于如何获取确切的浏览器名称和版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!