3

I tried using the User Agent class but in IE11, it shows Mozilla 5.0.

$this->agent->browser().' '.$this->agent->version();

I've tried using PHP's get_browser() and it displays the correct info, 'IE 11.0 for Desktop', but it slows the loading significantly.

$browser = get_browser(null, false);
dats
  • 123
  • 3
  • 12

1 Answers1

6

What version of CodeIgniter are you using? I just tested the following in my environment (CodeIgniter 3.0.6), and got back the correct response.

Controller:

$this->load->helper('url');
$this->load->library('user_agent');

$data['browser'] = $this->agent->browser();
$data['browserVersion'] = $this->agent->version();
$data['platform'] = $this->agent->platform();
$data['full_user_agent_string'] = $_SERVER['HTTP_USER_AGENT'];

View:

<?php 
    echo $browser . '<br />';
    echo $browserVersion  . '<br />';
    echo $platform . '<br />';
    echo $full_user_agent_string . '<br />';
?>

Output:

Internet Explorer

7.0

Windows 7

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3; OWASMIME/4.0500)

Yes, I tested in compatibility mode (which is why you see MSIE 7.0 referenced). I actually tried in all versions listed in the dev tools, and seemed to work on all.

For some reason, you are likely seeing part of the full user agent string. That string starts off with Mozilla/5.0. It doesn't mean that it is actually Mozilla. Here is some more history on why you see Mozilla/5.0 in the user agent string.

Community
  • 1
  • 1
cfnerd
  • 3,658
  • 12
  • 32
  • 44