In 2021, when we output the HTTP_USER_AGENT using IE, we get :
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Safari/537.36 Edg/89.0.774.45
So In order to look for IE in 2021, we write:
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Edg') !== FALSE {
echo 'You are using Internet Explorer.<br />';
}
?>
Or If we want to include old IEs we can use Declan's Support:
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE ||
strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== FALSE) ||
strpos($_SERVER['HTTP_USER_AGENT'], 'Edg') !== FALSE {
echo 'You are using Internet Explorer.<br />';
}
?>