Browscap Ini Directive Not Set

browscap ini directive not set

I don't think this is the "best" solution to detect is a browser supports what you need for your website :

  • first of all, browsers can lie -- they can send whatever thay want as User-Agent
    • And even if a given version of a support should support what you need, Javascript can still be disabled.
  • second, there are more "proper" way to detect what a browser can do or not, when it comes to Javascript.

For the second point, you should test if the browser actually supports what you need -- and not rely on a list such as the browscap one.


Still, to answer your question about browscap : there is a note at the bottom of the manual page for get_browser that says (quoting) :

Note: In order for this to work, your browscap configuration
setting in php.ini must point to the
correct location of the browscap.ini
file on your system. browscap.ini is
not bundled with PHP, but you may find
an up-to-date »
php_browscap.ini file here.

While browscap.ini contains
information on many browsers, it
relies on user updates to keep the
database current. The format of the
file is fairly self-explanatory.

So, you have to :

  • download the browscap file,
  • and set the browscap directive in your php.ini file, so it points to the file you downloaded.

get_browser(); function is not working properly

You never enabled the option:

;browscap = "C:\wamp\bin\php\php5.4.12\php_browscap.ini"
^---- comment/disable

Remove the ;.

How should I be setting browscap.ini file

You are to use the Full PATH and restart your server when you are done

Example

[browscap]
; http://php.net/browscap
browscap = "C:\xampp\php\extras\browscap.ini"

browscap.ini file and get_browser() aren't working

Today I phased this problem.

Just open the Applications/MAMP/bin/php/php7.1.1/conf/php.ini file and uncomment this line:

[browscap]
browscap = /Applications/MAMP/bin/php/browscap.ini

And finally restart the MAMP. get_browser() function will work.

Let me know if you solved this problem.

Cannot get browscap to load on OSX no matter which version I use or where I put it

I wonder what kind of valuable information you expect to get from this function.

But whatever it is, please be advised that it is considered bad practice, because you are essentially practicing server based client sniffing, and the only base of information is the user agent string, which can be anything and does not need to represent the real situation. Also, information like "javascript" can only represent the coded ability of the client, not the current configured abilities, which can be less.

If you still think the function to be of any use, you have to solve the task of getting a copy of that "browscap.ini" file this function wants to use, and you have to constantly update this file to include new browser versions.

There is a link to a file source on the documentation page of get_browser(). Download a file and point the INI setting to that location. Make sure to activate it by removing the semikolon.

Setting Up browscap for PHP

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!



Related Topics



Leave a reply



Submit