$_SERVER[‘user-agent’] to check for IE (including IE 11)
Summary: The user agent for IE 11 does not contain MSIE any more, which is a tactic deliberately set by Microsoft IE team.
Although browser sniffing is NOT considered as a best practice for web development, it is sometimes a must owing to various practical reasons. Recently, I need to hide a certain warning message if the browser is IE. However, the server-side script to test for IE is not as simple as before IE 11 as the IE team at Microsoft deliberately hide the MSIE string in the user-agent.
The Temporary Solution
If you use sever-side script to detect whether the browser is IE, you will need to test for either Trident (for IE 8+) or MSIE (for IE 10-) as below:
<?php
if(!(isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))):
?>