Forum Moderators: coopster

Message Too Old, No Replies

Detect MSIE older than using less than operator?

         

JAB Creations

7:28 pm on Jun 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here is my attempt at detecting an MSIE browser (in this instance, older then 5.5). The first part works fine but I'm still in the wrong valley as far as the browser's version number goes. Anyway here is what I have...

<?php
$ua = $_SERVER['HTTP_USER_AGENT'];
if ((stristr($ua, 'MSIE') == TRUE) & ($ua > 5.5))
{
echo 'You are using MSIE older then 5.5';
}
?>

What in the php dom would I use to detect a number in my $ua variable?

Here is something I just found as well..though it does not seem to work. I've tested it with IE 3.0, 4.0, 5.01, 5.5, and 6.0.

<?php
//HACK FOR DETERMINING HTMLAREA COMPATIBILITY
//make user agent into an array
$browser = explode(' ',$HTTP_USER_AGENT);
//Get key for MSIE if in the array
$i = array_search('MSIE',$browser);
//if found MSIE
if ($i > 0)
{
//Get MSIE version, trim trailing ;
$browserver = rtrim($browser[$i+1],";");
//check version is at least 5.5
if (floatval($browserver) >= 5.5)
echo 'You are using first';
} ELSE {
echo 'You are using second';
}
?>

Timotheos

8:22 pm on Jun 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you considered using the get_browser [php.net] function?

JAB Creations

10:50 pm on Jun 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you Timo! I'll check it out! :-)