1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

What is the best way to target older IE browsers with PHP?

Discussion in 'PHP' started by qwikad.com, Nov 1, 2015.

  1. #1
    I've started using

    (preg_match('/(?i)msie [5-8]/',$_SERVER['HTTP_USER_AGENT']))
    Code (markup):
    in one of my projects, but been wondering if there are other ways to do the same thing or is this pretty much standard?
     
    qwikad.com, Nov 1, 2015 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    First question will always be "why"?
    If the site is coded properly, it should degrade so that users with older browsers should get a working site, but without bells and whistles. And seriously, if you have users running Windows with ie < 8... Tell them to frickin upgrade.
     
    PoPSiCLe, Nov 1, 2015 IP
    sarahk and qwikad.com like this.
  3. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #3
    I totally agree. Over in Europe people are more prone to keep up with the latest technology. Not so much in the good ol' USA. I'll still target, at least, IE8 for a couple years before I remove that option. 4 years ago when I met now my wife, she had a laptop with IE6 on it. She didn't know that it was long outdated.
     
    Last edited: Nov 1, 2015
    qwikad.com, Nov 1, 2015 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    *headdesk*
    Well. You have a file called browsecap.ini which is meant to be used for this
    http://browscap.org
     
    PoPSiCLe, Nov 1, 2015 IP
  5. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #5
    Your piece of code will work perfectly, as expected. I wouldn't use anything else like browscap or any other libraries since they have unneeded overhead, unless you want to have other info handy.

    I would probably encapsulate it in its own static method for usage, but that is how I usually prefer shared functionality.
     
    ThePHPMaster, Nov 1, 2015 IP
    qwikad.com likes this.
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #6
    Best way? DON'T!!!

    If you are doing anything where you need to know that SERVER SIDE, you are doing something horrifyingly and terrifyingly WRONG in your HTML.

    Like relying on the dipshit HTML 5 tags that have no backwards compatibility... and even then if you REALLY want that nonsense, you can javascript polyfill them client side.

    This is one of those things that has no business even being done. If your HTML is well written, and you have properly done your CSS graceful degradation, there is NO reason for the server to care one way or the other!

    Besides, browser sniffing client or server side is garbage nonsense -- don't do it server side, and client side at least from a scripting standpoint, look for capabilities, not specific browser versions!
     
    deathshadow, Nov 1, 2015 IP
  7. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #7
    I agree with both @ThePHPMaster and @deathshadow , btw - there is no real reason to do it, and the problem with Browscap isn't just that it adds overhead, it probably also contain way more information than you need. It also needs to be updated continuously, unless you have config-capabilites of the server, and can include the file directly.
    But, as I said a few posts ago, and which @deathshadow just repeated - there should be no need to do this at all, because the page should work just fine for anyone visiting, whether they use IE4, Lynx, or the latest version of Chrome.
     
    PoPSiCLe, Nov 1, 2015 IP
  8. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #8
    I see. I am playing with a contenteditable rich text editor option for my site and as you know contenteditable is not supported by IE8. So I am showing the old rich text editor in IE8 and the new one in all other browsers. WYSIWYG editors is not my first choice, as I stated somewhere else, but they do offer a whole lot more options to users. More options - more fun - more money. But I go back and forth on that one. I am in in a beta mode. Will give it a week or so to see how the users respond to the new options and so forth. I can always go back to the old editor for all browsers if needed.
     
    qwikad.com, Nov 1, 2015 IP
  9. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #9
    I've just done a half marathon and helped out with the registration days - I got the job of guiding people who wanted a late entry through the entry process. They used realbuzz.com and I was flabbergasted to see on their registration page instructions about how you couldn't use IE.
    1. They should have known that we were using Chrome and hidden the warning
    2. WTF were they doing with a site that wasn't going to work with the major browsers? We might not like IE but we know our sites have to work on it.
    I might be wrong, but surely a site the size of realbuzz.com has a development person/people? Does anyone know?
     
    sarahk, Nov 1, 2015 IP