1

I am trying to use $_SERVER["HTTP_USER_AGENT"] to find a users browser and version.

Although when I use it with IE11 I get the following:

 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; WOW64; 
    Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; 
    .NET CLR 2.0.50727; .NET CLR 3.0.30729)

I thought it might be something to do with compatibility mode, but it doesn't seem to be on. Am I missing something?

Jay Webster
  • 179
  • 1
  • 3
  • 12
  • 6
    Are you sure compatibility mode is not on ? As a side remark, be carefull what you do after detection, this method is far from accurate or secure. – Laurent S. Jul 04 '13 at 11:29
  • Apparently this is the UA string for IE11 so it looks like there's something misconfigured on your end: http://www.nczonline.net/blog/2013/03/27/internet-explorer-11s-user-agent-string-what-does-it-mean/ – ta.speot.is Jul 04 '13 at 11:30
  • The original poster's sample *is* the Compatibility View setting for the IE11 User-Agent string. Warning: The nczonline.net post is outdated and does not have the current (non-Compat) UA String for IE11. – EricLaw Jul 04 '13 at 17:55

1 Answers1

0

Use the below code:

$browser = get_browser($_SERVER['HTTP_USER_AGENT']);

This will output as a array and you can get the proper list of using browser by print_r($browser);.

see this: Determine Browser's Version

Community
  • 1
  • 1
Code Lღver
  • 15,573
  • 16
  • 56
  • 75
  • As a note - `In order for this to work, your browscap configuration setting in php.ini must point to the correct location of the browscap.ini file on your system.` – swapnesh Jul 04 '13 at 11:36
  • get_browser(); requires the browscap.ini file to be presented in the php configuration :) – DaGhostman Dimitrov Jul 04 '13 at 11:36
  • I have tried the get_browser method, which works on chrome fine but I get the following for IE11: Array ( [browser_name_regex] => §^.*$§ [browser_name_pattern] => * [comment] => Default Browser [browser] => Default Browser [version] => 0 [majorver] => 0 [minorver] => 0 [platform] => unknown [platform_version] => unknown [alpha] => [beta] => [win16] => [win32] => [win64] => [frames] => [iframes] => [tables] => [cookies] => [javascript] => [vbscript] => [javaapplets] => [activexcontrols] => ) – Jay Webster Jul 04 '13 at 14:46