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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
hieloCommented:
sorry, change:
$_SERVER['USER_AGENT']

to:
$_SERVER['HTTP_USER_AGENT']
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mehul_PanchalCommented:
<?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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.