Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get exact browser name and version?

I have tried some solutions but I am unable to get exact name and version:

I am trying following code:

$browserAgent = $_SERVER['HTTP_USER_AGENT']; echo $browserAgent; 

Output of above code:

Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24 

But I am using:

Google Chrome 11.0.696.68 on    Ubuntu 10.04 

So I can find in Chrome/11.0.696.68 in output string but it is also showing some other browsers names that is confusing to extract exact browser name/version from string.

like image 751
Awan Avatar asked Jan 06 '12 06:01

Awan


People also ask

How do I find my browser name and version?

appName returns the string “Mozilla Firefox”. If it is Edge, navigator. appName returns the string “Microsoft Edge”. Using both objects, we can create an alert box to display what web browser the client is using and this navigator object contain all the information about web browser version, name, and more.

How can I get browser information in PHP?

The get_browser() function in PHP is an inbuilt function that is used to tell the user about the browser's capabilities. This function looks up the user's browscap. ini file and returns the capabilities of the user's browser.

How do I find my browser OS?

To detect the operating system on the client machine, one can simply use navigator. appVersion or navigator. userAgent property. The Navigator appVersion property is a read-only property and it returns a string which represents the version information of the browser.

How do you find the client's browser name?

How do I detect the browser name ? You can use the navigator. appName and navigator. userAgent properties.


1 Answers

Use get_browser()

From Manual:

echo $_SERVER['HTTP_USER_AGENT'] . "\n\n";  $browser = get_browser(null, true); print_r($browser); 

Will return:

Array (     [browser_name_regex] => ^mozilla/5\.0 (windows; .; windows nt 5\.1; .*rv:.*) gecko/.* firefox/0\.9.*$     [browser_name_pattern] => Mozilla/5.0 (Windows; ?; Windows NT 5.1; *rv:*) Gecko/* Firefox/0.9*/     [parent] => Firefox 0.9     [platform] => WinXP     [browser] => Firefox     [version] => 0.9     [majorver] => 0     [minorver] => 9     [cssversion] => 2     [frames] => 1     [iframes] => 1     [tables] => 1     [cookies] => 1     [backgroundsounds] =>     [vbscript] =>     [javascript] => 1     [javaapplets] => 1     [activexcontrols] =>     [cdf] =>     [aol] =>     [beta] => 1     [win16] =>     [crawler] =>     [stripper] =>     [wap] =>     [netclr] => ) 
like image 162
diEcho Avatar answered Sep 29 '22 03:09

diEcho