PHP IF IE Help

Discussion in 'PHP' started by ChristopherLeeMaher.Com, Jul 28, 2010.

  1. #1
    Hello,

    Is there a php code like

    <?php
    if ((navigator.userAgent.indexOf('Internet Explorer') != -1) || (navigator.userAgent.indexOf('IE') != -1)) {
    echo 'Is IE';
    }else{
    echo 'Not IE'
    }
    ?>
    PHP:
    Would That Work?, I can't test as i use ubuntu not windows
     
    ChristopherLeeMaher.Com, Jul 28, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    That's js or looks like it?, with PHP you'd do something along the lines of:

    <?php
    if (preg_match('~MSIE.+?Windows~i', $_SERVER['HTTP_USER_AGENT'])) {
    echo 'Is IE';
    } else {
    echo 'Not IE';
    }
    ?>
    PHP:
     
    danx10, Jul 28, 2010 IP
  3. ChristopherLeeMaher.Com

    ChristopherLeeMaher.Com Guest

    Messages:
    185
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank You,
    Just what i needed
     
    ChristopherLeeMaher.Com, Aug 15, 2010 IP