Is there a way to use PHP to detect if the page is being loaded using IE6?


Try checking their user agent for 'MSIE 6.'.

$using_ie6 = (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.') !== FALSE);

This is based on this user agent information.


You can detect IE6 with HTML this way

<!--[if IE 6]>
// ie6 only stuff here
<![endif]-->

Here's a link on how it's done in PHPWay Back Machine but I've seen many false positives in parsing the $_SERVER["HTTP_USER_AGENT"] for IE6


Many of the user-agent based answers on this page aren't too reliable because Opera often identifies itself with a user-agent string containing "MSIE 6.0", such as:

Mozilla/4.0 (compatible; MSIE 6.0; X11; Linux i686; en) Opera 9.51

This affects all versions of Opera 5 through 9 and even Opera 10 and can be turned on or off from within Opera. See this page.

A common approach I've seen is to test for "MSIE" and against "Opera". For example,

if (preg_match('/\bmsie 6/i', $ua) && !preg_match('/\bopera/i', $ua))
  echo "We have IE6!";