Created
April 3, 2017 12:08
-
-
Save douglascabral/6ee44fc02218936d32741f7c7f7f157e to your computer and use it in GitHub Desktop.
Detect IE 11 or below
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (preg_match('~MSIE|Internet Explorer~i', $_SERVER['HTTP_USER_AGENT']) || (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/7.0; rv:11.0') !== false)) { | |
//is IE 11 or below | |
} |
The solution by @koran2019 got me slightly closer to the issue, but I had additional LCTE
string in my user string (Lenovo touchscreen laptop) as so:
~Trident/7.0; Touch; LCTE; rv:11.0~
Adding a general wildcard helped here:
$badBrowser =
preg_match('~MSIE|Internet Explorer~i', $_SERVER['HTTP_USER_AGENT']) ||
preg_match('~Trident/7.0(.*)?; rv:11.0~', $_SERVER['HTTP_USER_AGENT']);
For anyone who is still having issues
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks 👏