PHP IE7 browser detection script

I'm looking for a PHP browser detection script.  If the user has IE7, I want to display a message on the page.  I have one that I'm playing with but it's not working correctly.  
ssailerAsked:
Who is Participating?
 
hieloConnect With a Mentor Commented:
sorry, change:
$_SERVER['USER_AGENT']

to:
$_SERVER['HTTP_USER_AGENT']
0
 
hieloCommented:
try:
if( preg_match('#MSIE\s+7#',$_SERVER['USER_AGENT']) )
{
 echo "IE7";
}

Open in new window

0
 
ssailerAuthor Commented:
Sorry, it's not working.  I'm not getting an error, just no output message at all.  
0
 
Mehul_PanchalConnect With a Mentor Commented:
<?php
if(preg_match('#MSIE\s+7#',$_SERVER['HTTP_USER_AGENT']) )
{
 echo "IE7";
}else if(preg_match('#MSIE\s+6#',$_SERVER['HTTP_USER_AGENT']) )
{
      echo "IE6";
}
else if(preg_match('#MSIE\s+8#',$_SERVER['HTTP_USER_AGENT']) )
{
      echo "IE8";
}
else
{
      echo "other browser";
}
?>
0
 
ssailerAuthor Commented:
Actually, it's not working.  It works for version 8 only, but not 7 - it doesn't detect version 7 in I.E.  Any suggestions?  
0
All Courses

From novice to tech pro — start learning today.