Hướng dẫn php check browser version

asked Jul 23, 2014 at 11:31

You can use get_browser. Example from PHP doc:

$browser = get_browser(null, true);
print_r($browser);

Result in:

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] =>
)

answered Jul 23, 2014 at 11:35

DebflavDebflav

1,1317 silver badges17 bronze badges

You can detect the browser by using Browser class download it from Github

Configuration

      include(/your-path/Browser.php);
$browser = new Browser();
        if( $browser->getBrowser() == Browser::BROWSER_IE && $browser->getVersion() >= 8 ) 
        {
            echo "Your browser is Internet explorer version 8";                                                                                                                                    
    }

similarly you can check all the browsers.

answered Mar 3, 2015 at 12:29

Hướng dẫn php check browser version

ManjuManju

7474 gold badges10 silver badges21 bronze badges

1

the best way to do this is as follows $browser = get_browser();

Note that this returns an object not a string. So to access the browser information, you could do this $brw=$browser->browser; echo $brw;

I hope this helps.

answered Dec 10, 2015 at 14:35

you can use the below code to find the browser + version this is html and javascript


    
      
       test

      

               


    


    
    
      

answered Jul 23, 2014 at 11:44

Hướng dẫn php check browser version

Ajit SinghAjit Singh

1,1121 gold badge14 silver badges23 bronze badges

I am trying to use PHP to detect which version of a browser is being used. so far I have managed to find out which browser is being used but not which version of that browser can anyone suggest what I need to be able to find this out

Here is what i have so far. Thanks

    
"/>