简体   繁体   English

PHP获取浏览器:输出混乱

[英]PHP get browser: confusing output

I have a list containing information on the user's web browser. 我有一个包含用户Web浏览器信息的列表。 The list was generated by PHP through a user requirements survey. 该列表由PHP通过用户需求调查生成。 The output looks like this: (sample): 输出如下所示:(示例):

  • Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0) Mozilla / 4.0(兼容; MSIE 8.0; Windows NT 6.1; Trident / 4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
  • Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.152 Safari/535.19 Mozilla / 5.0(Windows NT 6.0; WOW64)AppleWebKit / 535.19(KHTML,像Gecko)Chrome / 18.0.1025.152 Safari / 535.19
  • Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0) Mozilla / 5.0(兼容; MSIE 9.0; Windows NT 6.1; Trident / 5.0)
  • Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) Mozilla / 4.0(兼容; MSIE 8.0; Windows NT 5.1; Trident / 4.0; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727)
  • Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20100101 Firefox/11.0 Mozilla / 5.0(Windows NT 5.1; rv:11.0)Gecko / 20100101 Firefox / 11.0
  • Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.151 Safari/535.19 Mozilla / 5.0(Macintosh; Intel Mac OS X 10_7_3)AppleWebKit / 535.19(KHTML,如Gecko)Chrome / 18.0.1025.151 Safari / 535.19
  • Opera/9.80 (Windows NT 6.0; U; da) Presto/2.10.229 Version/11.62 Opera / 9.80(Windows NT 6.0; U; da)Presto / 2.10.229版本/ 11.62
  • Mozilla/5.0 (iPad; CPU OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3 Mozilla / 5.0(iPad; CPU OS 5_0_1,如Mac OS X)AppleWebKit / 534.46(KHTML,类似Gecko)版本/ 5.1 Mobile / 9A405 Safari / 7534.48.3
  • Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B179 Safari/7534.48.3 Mozilla / 5.0(iPhone; CPU iPhone OS 5_1,如Mac OS X)AppleWebKit / 534.46(KHTML,类似Gecko)版本/ 5.1 Mobile / 9B179 Safari / 7534.48.3
  • Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0 Mozilla / 5.0(Windows NT 6.1; WOW64; rv:14.0)Gecko / 20100101 Firefox / 14.0

Which is the actual web browser? 哪个是实际的网络浏览器? According to the PHP manual, it would be [parent], [platform], [browser], [version], but why does it say Safari and Chrome in one row, and why does "MSIE" appear inside the brackets? 根据PHP手册,它将是[父],[平台],[浏览器],[版本],但为什么它在一行中说Safari和Chrome,为什么“MSIE”出现在括号内?

These things identify the user agent. 这些东西标识用户代理。 But it looks like per platform or something the layout is a bit different. 但它看起来像每个平台或布局有点不同的东西。

I don't know what you would want to do with them but maybe this is of any help; 我不知道你想对他们做什么,但也许这有任何帮助; http://www.useragentstring.com/ http://www.useragentstring.com/

They also have an API with which you can get all the info you want. 他们还有一个API,您可以使用它获得所需的所有信息。

The first part means it's Mozilla 5.0 compatible - it's there for historical reasons and has no real use anymore, some browsers list other engines they support too. 第一部分意味着它与Mozilla 5.0兼容 - 它出于历史原因并且不再具有实际用途,一些浏览器列出了它们支持的其他引擎。 Then it is followed by Platform, Browser and build number/revision. 然后是平台,浏览器和内部版本号/修订版。

You may wish to use get_browser to help parse it. 您可能希望使用get_browser来帮助解析它。

As read from PHP's get_browser() documentation: 从PHP的get_browser()文档中读取:

For an output like: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3 , the following information is fetched: 对于如下输出: Mozilla / 5.0(Windows; U; Windows NT 5.1; en-US; rv:1.7)Gecko / 20040803 Firefox / 0.9.3 ,获取以下信息:

[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] =>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM