PHP Code to Detect IE Browsers

Sun, May 24, 2009

Programming & Code

The extremely buggy way that Internet Explorer renders CSS annoyed me again, this time because of the different way it displays elements with z-indexes.

I spent a couple of hours trying to fix the bug, failed, and decided to go about it another way. The problem lay in a CSS/Javascript rotating banner gallery ,so I used PHP to redirect all Internet Explorer users to a static version of that instead.

Here’s the PHP code that I used. This is the function, put it anywhere in your PHP file:

function detectIE()
{
if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))
return true;
else
return false;
}

And this is how I called it:

if detectIE() {
//if true, means the user's on IE
//do all the IE stuff here...
} else {
//all is fine
//use normal code here
}

Similar Posts:

Share and Enjoy!

Find this information useful or entertaining? Share it to the rest of the world!
  • Digg
  • del.icio.us
  • Facebook
  • StumbleUpon
  • Technorati
  • Twitter
  • FriendFeed
  • Reddit
, , , , , , , , , , , , , , , , , , , , , ,

This post was written by:

Alvin - Alvin is a Singaporean who's interested in marketing, techy stuff and likes to just figure out how the two can work with each other. On top of his blog, you can also follow him on Twitter.

Get Alvin's Report On How To Blog Successfully - Free!

blog comments powered by Disqus