Detect browser and OS with PHP?

By Daki - Last updated: Monday, June 22, 2009 - Save & Share - 3 Comments

chrome os38 Detect browser and OS with PHP?
Aaron asked:


I need a php that detects what browser the user is using to view my web page. I need it to detect. Internet explorer, Firefox, Safari, Opera, Chrome and others. I don’t need the version number.

I want it also to detect the Operating system of the user. I don’t need to know exactly what OS it is.

I prefer that it will give me the complete name of the Browser and OS.

For example. If the user is viewing the web page using Firefox 3 on windows xp, what I need this:

Windows
Firefox

The OS that I need to detect are: Windows, Mac, Linux and Others

What I mean with others is if the user is not using none of the Browsers or OS of the list.

Please return the value in two separate variables. One for the browser and one for the OS.

I need it in php not in javascript

I don’t have alot of expirience with php

kuapp.com/

Posted in Uncategorized • Tags: , , Top Of Page

3 Responses to “Detect browser and OS with PHP?”

Comment from Red 10th account
Time June 23, 2009 at 8:44 pm

i can haz google?
=

“I don’t have alot of expirience with php”
Ok, again I will repeat this, very slowly because I think it’s very VERY important. I. Can. Haz. GOOGLE.

Holy s**t, there’s a god damned PHP function for it. Ok, seriously dude, this is your answer:

Comment from JAB_au
Time June 24, 2009 at 10:07 am

See PHP manual:

get_browser returns an array, and you can get values from it like OS and browser.

Comment from Doug G
Time June 24, 2009 at 8:49 pm

echo $_SERVER['HTTP_USER_AGENT']

Write a comment