2

Do you know library for PHP that might help with parsing useragent string from browser? I want to extract at least those features:

  • language
  • browser (name and version)
  • os (name and version)

Any help would be appreciated.

wlk
  • 5,567
  • 6
  • 53
  • 72

2 Answers2

3

You can use get_browser(). Just make sure your database (the browscap.ini file) is up-to-date.

Álvaro González
  • 135,557
  • 38
  • 250
  • 339
3

This is a partial duplicate of Code to parse user agent string?

You can use the get_browser() function in PHP to parse the user-agent header and retrieve the browser and the OS versions.

However, the language information is not sent as part of the user-agent string. Instead, you probably want to look at the "Accept-Languagr" header, i.e. $_SERVER["HTTP_ACCEPT_LANGUAGE"]

Community
  • 1
  • 1
sagi
  • 5,469
  • 1
  • 29
  • 31