gamerfu
02-17-2010, 04:11 PM
How do I check for IE 6 and older browsers in PHP?
The function I want to run is anything older than IE6 should run other images, if anything newer or any other browser display PNGs:
$useragent = $_SERVER[‘HTTP_USER_AGENT’]);
if (preg_match(‘|MSIE ([0-6].[0-9]{1,2})|’,$useragent,$matched))
{
$browser_version=$matched[1];
$browser = ‘IE’;
$extList = array();
$extList['gif'] = 'image/gif';
$extList['jpg'] = 'image/jpeg';
$extList['jpeg'] = 'image/jpeg';
}
else
{
$extList['png'] = 'image/png';
}
The function I want to run is anything older than IE6 should run other images, if anything newer or any other browser display PNGs:
$useragent = $_SERVER[‘HTTP_USER_AGENT’]);
if (preg_match(‘|MSIE ([0-6].[0-9]{1,2})|’,$useragent,$matched))
{
$browser_version=$matched[1];
$browser = ‘IE’;
$extList = array();
$extList['gif'] = 'image/gif';
$extList['jpg'] = 'image/jpeg';
$extList['jpeg'] = 'image/jpeg';
}
else
{
$extList['png'] = 'image/png';
}