function getMSIE6() {
$userAgent = strtolower($_SERVER["HTTP_USER_AGENT"]);
if (ereg("msie 6", $userAgent) || ereg("msie 5", $userAgent)) {
return true;
}
return false;
}
Detect IE5 or IE6
Chris Coyier
on
Use preg_mach not ereg (depraced in PHP 5.3.0):
function getMSIE6() {
$userAgent = strtolower($_SERVER[“HTTP_USER_AGENT”]);
if (preg_match(“/msie 6/”, $userAgent) || preg_match(“/msie 5/”, $userAgent)) {
return true;
}
return false;
}
How’s about simply
function getMSIE56() {
return preg_match(“/msie [56]{1}/i”, $_SERVER[‘HTTP_USER_AGENT’]);
}
Using strpos(“msie 6”, $userAgent) would be even better than eregi and preg_match
@Emmanuel: Using strpos with strict type comparison operator === or !== is the way to go due to strange behavior of it.
Ah okay…