0

How do I get the browser version? I have done the browser detection part but every browser have different algorithm of its version release and its hard to get it. I already have looked in PHP's manual about get-browser function but every script seems out of my brain.

Santosh Kumar
  • 26,475
  • 20
  • 67
  • 118
  • Why do you want to determine the browser's version? – Bart Nov 01 '11 at 13:17
  • 2
    Out of curiousity: Why do you want to? Is there some reason you need to know? If it's so you know what it can do, that's usually a bad idea; instead, use **feature detection**. Some useful ones [here](http://kangax.github.com/cft/) and [here](http://www.modernizr.com/). This future-proofs your code and makes it so you don't have to constantly update it as browser versions change. – T.J. Crowder Nov 01 '11 at 13:18
  • I am making my own page which tells my system's detail. – Santosh Kumar Nov 01 '11 at 13:21
  • possible duplicate of [Any php code to detect the browser with version and operating system?](http://stackoverflow.com/questions/2142030/any-php-code-to-detect-the-browser-with-version-and-operating-system) – CharlesB Nov 02 '11 at 08:32

4 Answers4

3

You can get it easily with get_browser()

<?php
$browser = get_browser();
$version = $browser->version;
genesis
  • 50,477
  • 20
  • 96
  • 125
2

Your only chance is to grab the User-Agent from the $_SERVER array. And there is no rule that forces a browser to include its version.

Till Helge
  • 9,253
  • 2
  • 40
  • 56
2

A google search for 'php browser version detection' return get_browser() as the first result. Please search before posting.

Whetstone
  • 1,199
  • 8
  • 8
0

I have found PPK's JavaScript-based browser detection code to be very reliable.

mvark
  • 2,105
  • 2
  • 21
  • 36