Categories
Uncategorized

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 with conditional comments). Here’s how.

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:


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


The strpos() function helps you find the position of the string “MSIE 6.” within the string returned by $_SERVER[‘HTTP_USER_AGENT’]. Done.

Credit where credit’s due: http://stackoverflow.com/questions/671890/can-i-detect-ie6-with-php

Leave a Reply

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