Get browser saying 'default browser'

106 Views Asked by At

I am using get_browser to keep statistics for my web site. However, all of the results are browser = 'Default Browser' and platform = 'unknown'. I checked phpinfo() and the browscap.ini path is correct. What else would be causing this problem? It does this in all browsers.

My Code:

print_r(get_browser(null, true));
2

There are 2 best solutions below

0
On

I wouldn't use get_browser() since it uses the browscap file, which is constantly being updated and is more for seeing what the browser can do instead of getting the name of the browser. (browscap - short for BROWSer CAPabilities). You can find many other ways to do this online, with a quick Google search.

4
On

You can use getallheaders() http://php.net/manual/en/function.getallheaders.php

$headers = getallheaders();
$browser = $headers['User-Agent'];