...

View Full Version : If internet explorer 8



levani
05-06-2009, 08:53 PM
How can I get information whether an user uses internet explorer 8 or not? I use this code for IE 6, but it doesn't seem to work on IE 8.


<?php
//if the browser is Microsoft IE
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
if (ereg('MSIE 6',$_SERVER['HTTP_USER_AGENT']))
include (TEMPLATEPATH . '/form_ie.php');
} else {
include (TEMPLATEPATH . '/form_other.php');
}
?>

What I want to do is to execute different code if user comes from IE6 or older and different for all other browsers (including IE 7 and 8).

Any ideas?

mlseim
05-06-2009, 09:04 PM
This might help ...

http://www.php-scripts.com/20050912/12/

I'm guessing you can alter [0-9] to [0-6] or [7-9] to pick out the version you want.

venegal
05-06-2009, 09:04 PM
You did change that '6' to an '8' there, right?

Anyway, the surefire way is to use conditional comments in your html, but that means that you will need at least two http-requests until you get that browser information into your server side script.

levani
05-06-2009, 09:19 PM
My code above works as it must be on every browser, but IE8. On IE8 it doesn't include neither "form_ie.php" nor "form_other.php". Why? :)

I want it to include form_other.php if the browser is IE8...

venegal
05-06-2009, 09:50 PM
Ok, I see the problem. What you are doing is:

Are you an IE? If yes, are you IE6? Then you get form_ie.
Oh, you're not an IE? Then you get form_other.

No IE, except 6, will ever get anything included.

If you want only IE6 to get form_ie and every other browser form_other, do it like this:



if (ereg('MSIE 6',$_SERVER['HTTP_USER_AGENT'])){
include (TEMPLATEPATH . '/form_ie.php');
} else {
include (TEMPLATEPATH . '/form_other.php');
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum