douweiluo0600 2012-02-05 16:22
浏览 39
已采纳

PHP get_browser在WAMP和Linux服务器上返回不同的结果

When using the get_browser function in PHP on:

  • Linux server - works perfectly.
  • WAMP server - returns "Default Browser"

I have just downloaded the latest browscap.in file.

My user_agent is: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1

WAMP:

Array
(
    [browser_name_regex] => §^.*$§
    [browser_name_pattern] => *
    [browser] => Default Browser
    [version] => 0
    [majorver] => 0
    [minorver] => 0
    [platform] => unknown
    [alpha] => 
    [beta] => 
    [win16] => 
    [win32] => 
    [win64] => 
    [frames] => 
    [iframes] => 
    [tables] => 
    [cookies] => 
    [backgroundsounds] => 
    [javascript] => 
    [vbscript] => 
    [javaapplets] => 
    [activexcontrols] => 
    [isbanned] => 
    [ismobiledevice] => 
    [issyndicationreader] => 
    [crawler] => 
    [cssversion] => 0
    [aolversion] => 0
)

Server:

Array
(
    [browser_name_regex] => �^mozilla/5\.0 \(.*windows nt 6\.1.*wow64.*rv:.*\) gecko/.* firefox/9\..*$�
    [browser_name_pattern] => Mozilla/5.0 (*Windows NT 6.1*WOW64*rv:*) Gecko/* Firefox/9.*
    [parent] => Firefox 9.0
    [platform] => Win7
    [win32] => 
    [win64] => 1
    [browser] => Firefox
    [version] => 9.0
    [majorver] => 9
    [frames] => 1
    [iframes] => 1
    [tables] => 1
    [cookies] => 1
    [javascript] => 1
    [javaapplets] => 1
    [cssversion] => 3
    [minorver] => 0
    [alpha] => 
    [beta] => 
    [win16] => 
    [backgroundsounds] => 
    [vbscript] => 
    [activexcontrols] => 
    [isbanned] => 
    [ismobiledevice] => 
    [issyndicationreader] => 
    [crawler] => 
    [aolversion] => 0
)

QUESTION: How do I fix this issue in WAMP so that it behaviours like the linux server?

  • 写回答

2条回答 默认 最新

  • doudian7996 2012-02-11 00:21
    关注

    I suggest to use this "Standalone replacement for php's native get_browser() function" https://github.com/garetjax/phpbrowscap

    This library is suggested to be used in the Browsercap page

    Here is a list of the features:

    • Fast
    • Standalone
    • Even faster parsing many user agents
    • Fully get_browser() compatible
    • Often faster and more accurate than get_browser()
    • Fully PHP configuration independent
    • User agent auto-detection
    • Returns object or array
    • Parsed .ini file cached directly into PHP arrays
    • Accepts any .ini file (even ASP and lite versions)
    • Auto updated browscap.ini file and cache from remote server with version checking
    • Configurable remote update server
    • Fully configurable (since 0.2)
    • PHP4 and PHP5 compatible (PHP4 version deprecated)
    • Released under the MIT License
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序