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,695
  • 6
  • 54
  • 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
  • 142,137
  • 41
  • 261
  • 360
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,619
  • 1
  • 30
  • 31