3

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.

0

2 Answers 2

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"]

1
3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.