Detect user’s browser type

Some of you may wonder how a website can be able to detect my browser type. Today I will show you a way to detect what type of browser a user is using, so you can collect this data for your statistic purposes.
The codes below is only applied for php on *nux server

Then you can use this variable $browser_type to store in your database or use it to count how many browser type has been used to read your website.