Skip to content

Instantly share code, notes, and snippets.

@dustyf
Last active December 28, 2015 22:19
Show Gist options
  • Save dustyf/7571030 to your computer and use it in GitHub Desktop.
Save dustyf/7571030 to your computer and use it in GitHub Desktop.
Detect IE Versions in PHP and return either the version or less than indicators.
/**
* Detect the Browser
*/
function dlf_ie() {
$ie_version = '';
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.') !== false ) {
$ie_version = 'ie6';
} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7.') !== false ) {
$ie_version = 'ie7';
} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 8.') !== false ) {
$ie_version = 'ie8';
} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 9.') !== false ) {
$ie_version = 'ie9';
} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 10.') !== false ) {
$ie_version = 'ie10';
}
return $ie_version;
}
function dlf_ltie10() {
$ie_version = dlf_ie();
$lt = '';
if ( $ie_version == 'ie6' || $ie_version == 'ie7' || $ie_version == 'ie8' || $ie_version == 'ie9' ) {
$lt = 'ltie10';
} else {
$lt = false;
}
return $lt;
}
function dlf_ltie9() {
$ie_version = dlf_ie();
$lt = '';
if ( $ie_version == 'ie6' || $ie_version == 'ie7' || $ie_version == 'ie8' ) {
$lt = 'ltie9';
} else {
$lt = false;
}
return $lt;
}
function dlf_ltie8() {
$ie_version = dlf_ie();
$lt = '';
if ( $ie_version == 'ie6' || $ie_version == 'ie7' ) {
$lt = true;
} else {
$lt = false;
}
return $lt;
}
function dlf_ltie7() {
$ie_version = dlf_ie();
$lt = '';
if ( $ie_version == 'ie6' ) {
$lt = 'ltie7';
} else {
$lt = false;
}
return $lt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment