0

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 Answers2

0

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

$headers = getallheaders();
$browser = $headers['User-Agent'];
Sesertin
  • 462
  • 2
  • 11
  • Is that any different than $_SERVER ['HTTP_USER_AGENT']? –  Jun 19 '14 at 20:41
  • To tell the trouth I have never researched the topic but my best guess is: they should be just the same. – Sesertin Jun 19 '14 at 20:42
  • I tested that and it gives the same results. Thanks, though. –  Jun 19 '14 at 20:44
  • How are you testing? I mean probably your test request is passing the default_browser flag if you are using curl or anything other than a browser. – Sesertin Jun 19 '14 at 20:46
0

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.