John Magnolia
John Magnolia

Reputation: 16823

PHP get_browser returns different results on WAMP and linux server

When using the get_browser function in PHP on:

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?

Upvotes: 1

Views: 423

Answers (2)

Francesco Terenzani
Francesco Terenzani

Reputation: 1391

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

Upvotes: 1

antyrat
antyrat

Reputation: 27755

Seems that your php.ini file didn't contain path to browscap ini file.

Look if there present this setting:

[browscap]
browscap = /path/to/your/php_browscap.ini

Upvotes: 1

Related Questions