User-agents, just like most other things, can bee spoofed. So that means that there is no 100% chance of detecting a browser.
Now that the security aspect of it is out of the way...
PHP has an extension called "browsercap", that does mostly the same as "Modernizr", and without the haste of installing third-party client libraries.
I've used it before, and it's quite solid, except for obvious flaws.
Link:
http://php.net/manual/en/function.get-browser.php