Joe
Joe

Reputation: 8292

What is Default Browser in PHP get_browser?

I see search results in SO of get_browser resulting Default Browser for example Chrome Users, I on the other hand am not sure of what the users are using I think Default Browser results in my case are robots/crawlers/etc.

I'm using the full_php_browscap.ini version and it gets a Default Browser value for the browser. What is Default Browser? And when does get_browser return Default Browser?

Upvotes: 1

Views: 2036

Answers (2)

Soyoes
Soyoes

Reputation: 940

I wasted much time to learn how to use that func,

While I finally understood that man should never use that function, it will kill your performance !!!

try with/without get_browser to check the result.

ab -c 100 -n 100 http://yourserver/

use preg_match_all('/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i', $_SERVER['HTTP_USER_AGENT']) instead

Upvotes: 0

Rembunator
Rembunator

Reputation: 1315

I think 'Default Browser' is returned when the user-agent is unknown. Either the agent is missing from browscap or maybe browscap can't be found.

You can use $_SERVER['HTTP_USER_AGENT'] to find out wich user-agent was used. Maybe this string is just made up (robots indeed).

Someone replied the folowing on the php manual page for get_browser:

We are using get_browser() function for useragent Mozilla/4.0 (compatible; MSIE 4.01; Windows NT) the get_browser function is returning as Default Browser and Platform = unknown.

So i added this to my browscap.ini manually:

[Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)] Parent=IE 4.01 Platform=WinNT

I Hope this helps.

Upvotes: 2

Related Questions