Use PHP to Detect Internet Explorer 11 and Below

Internet ExplorerAs I’ve mentioned before, Microsoft dropped conditional comment support in Internet Explorer 10 (and didn’t bring it back in IE 11). This means that you must use JavaScript or PHP to detect Internet Explorer 10 (IE10) or Internet Explorer 11 (IE11), which is a darn shame.

It’s pretty easy to do, however. Especially if you are targeting ALL versions of Internet Explorer. Here’s what I currently do:

if (preg_match('~MSIE|Internet Explorer~i', $_SERVER['HTTP_USER_AGENT']) || (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/7.0; rv:11.0') !== false)) {

It’s simple and it works well. The first part targets IE10 and below, while the second targets the newer IE11 user agent. Modify as needed.

Incoming search terms:

  • javascript detect internet explorer 11
  • detect ie11
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1830 PP0B-0awwoLtLNGQK_ldOA99UvnR3QmTVwMAN19A6Gc5d7uNTVilUsS6LT_IS8MI 97e68a206b563d184d9a9fdd86a3e1bb02bbea88&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1832 InnQevcbS5Lc-wlfCy4fePuWOl82JLh_jGiCNii8hwXwnmvJCKuwJTjjmgyAqj9M 9e128b9f772cdbd2d2856652fc1bc4c12e16fbee&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • php detect browser ie9 ie10 ie11
  • php detect ie

Comments

  1. By IEDETECT

    Reply

  2. By Raul A. Cantillo

    Reply

Leave a Reply

Your email address will not be published.