0

I recently started to use the get_browser() function inside of PHP and I encountered a major issue. I am trying to return the browser that the user is using back to the user but when I run the code:

$browser = get_browser(null, true);
print($browser['browser']);

It returns 'DefaultBrowser'. I updated my Browscap.ini file and specified the location in my php.ini file but it seemed to change nothing. Any solutions, I am very new to PHP. Thanks

4

1 回答 1

0

不幸的是,bro​​wscap.ini 文件没有像浏览器那样经常更新(现在非常频繁)。幸运的是,您可以自己编辑文件并复制粘贴其中的最新浏览器,然后增加版本号。通常,功能将相同或更好,因此不会引起问题。

[编辑]

browscap.ini 文件包含如下条目

[IE 10.0]
Parent=DefaultProperties
Comment="IE 10.0"
Browser="IE"
Version=10.0
MajorVer=10
MinorVer=0
Beta=true
Win32=true
Frames=true
IFrames=true
Tables=true
Cookies=true
BackgroundSounds=true
JavaScript=true
VBScript=true
JavaApplets=true
ActiveXControls=true
CssVersion=3

[Mozilla/*(*MSIE 10.*Windows NT 6.1*64*Trident/6.0*)*]
Parent=IE 10.0
Platform="Win7"
Platform_Version=6.1
Win32=false
Win64=true

版本的一般条目,以及特定平台的一些条目。您可以复制这些,将版本从 10 更改为 11,然后将它们添加到文件中。

所以这两个条目将成为

[IE 11.0]
Parent=DefaultProperties
Comment="IE 11.0"
Browser="IE"
Version=11.0
MajorVer=11
MinorVer=0
Beta=true
Win32=true
Frames=true
IFrames=true
Tables=true
Cookies=true
BackgroundSounds=true
JavaScript=true
VBScript=true
JavaApplets=true
ActiveXControls=true
CssVersion=3

[Mozilla/*(*MSIE 11.*Windows NT 6.1*64*Trident/6.0*)*]
Parent=IE 11.0
Platform="Win7"
Platform_Version=6.1
Win32=false
Win64=true
于 2013-12-06T16:33:43.747 回答