WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using some HTML5 functionality that only works on IE9 and I need to detect whether visitors are running on IE8 or below (mainly just IE8 or 7 of course). I've tried some plugins but the one that was working didn't seem to support IE9 (just up to 8). It's called PHP Browser Detection (http://wordpress.org/extend/plugins/php-browser-detection/)

share|improve this question
up vote 0 down vote accepted

I would suggest using that plugin, but slightly modifying it for your needs. For example, you can find the code block in php-browser-detection.php that does the IE7 check:

function is_IE7 (){
    $browserInfo = php_browser_info();
    if(isset($browserInfo['browser']) && $browserInfo['browser']=='IE' && $browserInfo['majorver'] == '7')
        return true;
    return false;   

To create a version that will detect IE 8, add a new function that does the same thing, but just with the majorver set to 8:

function is_IE8 (){
    $browserInfo = php_browser_info();
    if(isset($browserInfo['browser']) && $browserInfo['browser']=='IE' && $browserInfo['majorver'] == '8')
        return true;
    return false;   
share|improve this answer
Thanks! That worked like a charm. I did try adding new functions for IE 9 (is_IE9() and is_lte_IE9()) but they didn't seem to work. Regardless, using the code below I think I'm good to go. Thanks again, GavinR! if(is_IE7() || is_IE8()) { echo 'This is IE 7 or IE 8. Bummer.'; } else { echo 'Nice modern browser you got there!'; } – Brian Larson Dec 2 '11 at 18:39
Apologies for all the re-edits. I can't get my code snippet to display properly using the preceding 4 spaces. Does that only work in answers and not answer comments? Would it be best for me to answer my own question here combining my little logic with your added function to the plugin? Sorry for the n00b factor here on Stack Exchange. – Brian Larson Dec 2 '11 at 18:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.