Browser Detecion...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Browser Detecion...

Post 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.
Vicious
Forum Contributor
Posts: 105
Joined: Fri Jun 20, 2003 12:40 pm

Post by Vicious »

Code: Select all

SERVER['HTTP_USER_AGENT']
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Post 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
SBro
Forum Commoner
Posts: 98
Joined: Tue Sep 30, 2003 10:06 pm

Post by SBro »

Code: Select all

$_SERVER['HTTP_USER_AGENT'];
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Post 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?
SBro
Forum Commoner
Posts: 98
Joined: Tue Sep 30, 2003 10:06 pm

Post 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']
Post Reply