WordPress Code Snippets

A fresh mix of code snippets and tutorials

PHP Detect All Versions of IE


Quick code snippet for detecting all versions of good ’ol IE (Internet Explorer).

Using PHP’s preg_match(), it is possible to match all versions of IE. Consider the following example:

Here we are sanitizing the user agent and storing it as a variable named $ua. We then use preg_match() to pattern-match for IE 10 and below (first “or” condition) and also IE 11 (second “or” condition). Cumulatively this accounts for all currently existing versions of Internet Explorer.

Remember to update this technique with the advent of future versions of IE!

Show Support

Like our new Facebook Page to show support!