drgawfsf1069 2011-03-14 17:47
浏览 44
已采纳

PHP:如果是Internet Explorer 6,7,8或9

I want to do a conditional in PHP for the different versions of Internet Explorer along the lines of:

if($browser == ie6){ //do this} elseif($browser == ie7) { //dothis } elseif...

I have seen many variations on similar code, but looking for something super simple that is very easy to code to do some simple if and else and do different things.

Thanks

EDIT: I need this to show some different messages to users so CSS conditionals etc are no good.

  • 写回答

17条回答 默认 最新

  • duanma8207 2011-03-14 17:59
    关注

    This is what I ended up using a variation of, which checks for IE8 and below:

    if (preg_match('/MSIE\s(?P<v>\d+)/i', @$_SERVER['HTTP_USER_AGENT'], $B) && $B['v'] <= 8) {
        // Browsers IE 8 and below
    } else {
        // All other browsers
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(16条)

报告相同问题?

悬赏问题

  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了