It is possible to use PHP to check whether your site visitor uses Internet Explorer
and output some IE-specific text or HTML/CSS markup .
In PHP superglobal array $_SERVER there is usually HTTP_USER_AGENT element which contains browser-specific id string Internet Explorer uses something like Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"as id-string, depending on platform and version. Every version of IE has "MSIE" part in HTTP_USER_AGENT string, so it is possible to detect IE simply by scanning $_SERVER['HTTP_USER_AGENT'] for string "MSIE". Example: function ae_detect_ie below returns true if Internet Explorer has been detected. source code: php <?phpFor a maximum speed, we use strpos function instead of strstr, preg_match or other PHP string-search functions. Note, that if you want to check for IE in several places, it is better to store function value in some variable, to avoid serveral similar string-searches. Here is the example of detecting Internet Explorer and suggesting user to get another browser: source code: php <!-- function ae_detect_ie (see code above) is pasted here -->
|
|