Page 1 of 1

Browser Detecion...

Posted: Mon May 09, 2005 11:04 pm
by Mr Tech
How do I detect whether the users browser is either IE 5.5+, Firefox 1.0+, Mozilla 1.3+ or Netscape 7+?

I cant find a script that does exactly this.

Posted: Mon May 09, 2005 11:15 pm
by Vicious

Code: Select all

SERVER['HTTP_USER_AGENT']

Posted: Mon May 09, 2005 11:29 pm
by Mr Tech
Huh? I'm getting this:

Parse error: parse error, unexpected '[' in c:\program files\easyphp\www\wysiwyg\editor\test.php on line 2

Posted: Mon May 09, 2005 11:34 pm
by SBro

Code: Select all

$_SERVER['HTTP_USER_AGENT'];

Posted: Mon May 09, 2005 11:42 pm
by Mr Tech
Thanks. OK, I'm getting this:

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3 StumbleUpon/1.9995

How do I get the info what I need out of that so I can tell if it is the browsers mentioned in my first post?

Posted: Mon May 09, 2005 11:49 pm
by SBro
Use a function such as strstr() to check if the browser you are looking for is contained in the string returned by $_SERVER['HTTP_USER_AGENT']