Search code examples
phpwampbrowscap

Setting Up browscap for PHP


I have just tried enabling php_browscap.ini so that I can use the get_browser function.

However, it seems to display an empty array?

$user_agent = get_browser(null, true);

print_r($user_agent);

In my php.ini file, I have the following:

[browscap]
; http://php.net/browscap
browscap = C:/wamp/bin/php/php5.3.0/extra/php_browscap.ini

I am probably missing something simple?

Update

Output I get:

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

Solution

  • You could find if there's something else failing using tools like ProcMon. This tool will tell you which files had been accessed, and what was the result. So, you have to open it, highlight the browsercap ini's path, restart the webserver and see if any of this scenarios fits:

    • File doesn't exist
    • Permission denied
    • Finding wrong path
    • Doesn't appear at all

    ProcMon is a Wonderful tool if you're in Windows.

    If you find any of those scenarios, and don't know what to do, just edit your question :-)

    Good luck!