How to detect the client's operating system?

How to detect the client browser’s operating system?
Some websites like software downloads show the system specific pages.

By this, the user does not have to search for a compatible download or download incompatible software.

I think, parsing USER_AGENT is a difficult way unless we know a list of browsers, OS and their versions.

Yes, it’s difficult and only works if useragent string contains OS info.
There is a decent class on PEAR for doing it :

Check out the API