PHP - get_browser()结果 [英] PHP - get_browser() results
问题描述
我使用了 get_browser()
功能,我安装了最新的 php_browscap.ini
文件< A HREF =http://tempdownloads.browserscap.com/相对=nofollow> http://tempdownloads.browserscap.com/ ,更新了我的的php.ini 文件反映新的位置。
I'm using the get_browser()
function, and I installed the latest php_browscap.ini
file from http://tempdownloads.browserscap.com/, updated my php.ini file to reflect the new location.
下面是我简单的code我从PHP的网站上收集到的:
Here's my simple code I've gleaned from PHP's site:
<?php
echo $_SERVER['HTTP_USER_AGENT'];
echo "<br>";
echo "<br>";
$browser = get_browser(null, true);
print_r($browser);
?>
和的结果是这样的:
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0
Array ( [browser_name_regex] => �^mozilla/5\.0 \(.*windows nt 6\.1.*wow64.*\).*gecko/.*firefox/21\..*$� [browser_name_pattern] => Mozilla/5.0 (*Windows NT 6.1*WOW64*)*Gecko/*Firefox/21.* [parent] => Firefox 21.0 [platform] => Win7 [platform_version] => 6.1 [win32] => [win64] => 1 [comment] => Firefox 21.0 [browser] => Firefox [version] => 21.0 [majorver] => 21 [minorver] => 0 [beta] => 1 [frames] => 1 [iframes] => 1 [tables] => 1 [cookies] => 1 [javascript] => 1 [javaapplets] => 1 [cssversion] => 3 [alpha] => [win16] => [backgroundsounds] => [vbscript] => [activexcontrols] => [ismobiledevice] => [issyndicationreader] => [crawler] => [aolversion] => 0 )
我看到在 [browser_name_regex] 部分一个奇怪的字符。结果
该预期是什么?
I'm seeing a weird character in the [browser_name_regex] section.
Is that expected?
另外,我
推荐答案
虽然这不是预期,但它是允许的。我从 get_browser()
函数是 [browser_name_regex] =&GT输出; §^ * $§
。它只是有两个段落,而不是施加的斜线 /^.*$/
。
Although it's not expected, but it's allowed. My output from the get_browser()
function was [browser_name_regex] => §^.*$§
. It just has two paragraphs instead of exerted slashes /^.*$/
.
说明:
分隔符可以是除反斜线(\\)和空字节任何非字母数字,非空白ASCII字符。 (链接)
Delimiters can be any non-alphanumeric, non-whitespace ASCII character except the backslash (\) and the null byte. (link)
你所看到的仅仅是包裹着分隔符是\\ xA7一个PCRE模式。要得到
浏览器匹配你需要一个版本的browscap.ini它通过的链接可下载
在文档页面。 (链接)
What you see is merely a pcre pattern wrapped with delimiter which is \xA7. To get browsers matching you'll need a browscap.ini which is downloadable by the links on the doc page. (link)
这篇关于PHP - get_browser()结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!