php – check if Internet Explorer

if(preg_match(‘/(?i)msie [1-9]\.0/’,$_SERVER[‘HTTP_USER_AGENT’]))

{ do/say something }


{ do/say something else }

Though the above won’t work for IE 11.

As $_SERVER[‘HTTP_USER_AGENT’]  returns a string containing the ‘Trident’ substring for IE, we will look for this text to determine if we have a IE user browsing our page:

if (strpos($_SERVER[‘HTTP_USER_AGENT’], ‘Trident’) !== false )  { }


This entry was posted in Others and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *