WordPress Code Snippets

A fresh mix of code snippets and tutorials

PHP: Target IE less than 9


Recently I haven’t had time to bother with old versions of IE (less than 9), so I use the following PHP function to target IE 6, 7 and 8.

Want to target/filter Internet Explorer versions less than 9? Here is the function:

There are a million ways to apply this, but keep in mind that it’s trivial to spoof the user agent, and many probably do. Best advice is to use only for stuff that’s not mission critical so that your content is always available. Although admittedly, I use this script to redirect users of old IE to an “upgrade your browser” page. Really there is no excuse for using IE less than 9. And some would argue any version of IE ;)

Show Support

Like our new Facebook Page to show support!