'HTTP_USER_AGENT'
Contents of the User-Agent: header from the current request, if there is one. This is a string denoting the user agent being which is accessing the page. A typical example is: Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586). Among other things, you can use this value with get_browser() to tailor your page's output to the capabilities of the user agent.
So I assume you'll be able to get the browser name/id from the $_SERVER["HTTP_USER_AGENT"] variable.
PHP has a function called get_browser() that will return an object (or array if you so choose) with details about the users' browser and what it can do.
This is not a surefire way (as it reads from HTTP_USER_AGENT, which can be spoofed, and will sometimes be analyzed wrong by php), but it's the easiest one that you can find as far as I know.
/**
* Returns the version of Internet Explorer or false
*/
function isIE(){
$isIE = preg_match("/MSIE ([0-9]{1,}[\.0-9]{0,})/",$_SERVER['HTTP_USER_AGENT'],$version);
if($isIE){
return $version[1];
}
return $isIE;
}
Checking for MSIE only is not enough to detect IE. You need also "Trident" which is only used in IE11. So here is my solution which worked an versions 8 to 11.
if you have Internet Explorer 11 and it's running over a touch screen pc, you must use:
preg_match('/Trident/7.0; Touch; rv:11.0/', $_SERVER['HTTP_USER_AGENT'])
instead of:
preg_match('/Trident/7.0; rv:11.0/', $_SERVER['HTTP_USER_AGENT'])