get_browser unavailable

I cannot use the get_browser php function, the docs says that I need to set right directory way to browscap.ini, but I unable to because php.ini is configurable only from panel, where I’m really limited there(only few things I am able to change).
So is that possible to ‘enable’ that function somehow?

The function itself is enabled, but we haven’t loaded any browscap rules (nor do we have any intention to add any), so get_browser() is not really going to work.

However, there are plenty of other libraries out there which can also do browser detection, feature detection or both, and don’t require any special PHP configurations to work.

I’m sure you can find a good alternative to do what you’re looking for with some searching yourself. If you would like to discuss it more here, could you please explain a bit more on what you’re actually trying to do?

Uh, just need to know browser which user uses to access my page and do some things to different browsers.

@MrJunior said:
Uh, just need to know browser which user uses to access my page and do some things to different browsers.

For starters, feature whitelisting based on the user agent sent by a browser is considered bad practice and you shouldn’t do it. For example, if you look at the user agent string for Microsoft Edge:

Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10136

You see it contains references to:

  • Mozilla
  • KHTML (Konqueror browser)
  • Gecko (Firefox browser)
  • Chrome
  • Safari

The only reason why these identifiers need to be so long and confusing is because people decided that “I want to use browser feature X, and only browser Y supports that [at the moment]. Let’s make it so that only people using browser Y can access my website and reject everyone else [regardless of whether their browser actually supports feature X]”.

If you still insist on doing this bad practice, here are some alternative libraries which let you do that:

Or, if your application is simple, you could just parse $_SERVER['USER_AGENT'] manually.