Detect IE6 with PHP

Let’s say you want to server-side detect whether a user’s browser is the dreaded IE6 using PHP (instead of on the client side, which is usually done the conditional comments <!–[if IE 6] –>).

PHP’s function get_browser() is a way to get there, as this function gives you an array or object with info on the user’s browser’s capabilitties. But if you just want a quick and dirty way to find if it’s IE 6 they are using, you can just access the global variable $_SERVER[‘HTTP_USER_AGENT’] to get it done: