you can use $_SERVER['HTTP_USER_AGENT']
as found in the php manual.
However, be aware that this can be changed by the user and some browsers even provide the ability to do this VERY easy (e.g. Konqueror). A lot of plugins are available to do the same.
Never ever trust this string.