Code Snippet
Detect IE5 or IE6
function getMSIE6() {
$userAgent = strtolower($_SERVER["HTTP_USER_AGENT"]);
if (ereg("msie 6", $userAgent) || ereg("msie 5", $userAgent)) {
return true;
}
return false;
}
function getMSIE6() {
$userAgent = strtolower($_SERVER["HTTP_USER_AGENT"]);
if (ereg("msie 6", $userAgent) || ereg("msie 5", $userAgent)) {
return true;
}
return false;
}
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…
DigWP
A book and blog co-authored by Jeff Starr and myself about the World's most popular publishing platform.
Quotes on Design
Design, like Art, can be an elusive word to define and an awfully fun thing to have opinions about.
HTML-Ipsum
One-click copy to clipboard access to Lorem Ipsum text that comes wrapped in a variety of HTML.
Bookshelf
Hey Chris, what books do you recommend? These, young fertile mind, these.