問(wèn)題描述
我想在 PHP 中為不同版本的 Internet Explorer 執(zhí)行以下操作:
I want to do a conditional in PHP for the different versions of Internet Explorer along the lines of:
if($browser == ie6){//做這個(gè)} elseif($browser == ie7) {//做這個(gè) } elseif...
我已經(jīng)看到類似代碼的許多變體,但正在尋找一些非常簡(jiǎn)單的代碼來(lái)執(zhí)行一些簡(jiǎn)單的 if 和 else 并執(zhí)行不同的操作.
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.
謝謝
我需要這個(gè)來(lái)向用戶顯示一些不同的消息,所以 CSS 條件等不好.
I need this to show some different messages to users so CSS conditionals etc are no good.
推薦答案
這是我最終使用的一個(gè)變體,它檢查 IE8 及以下:
This is what I ended up using a variation of, which checks for IE8 and below:
if (preg_match('/MSIEs(?P<v>d+)/i', @$_SERVER['HTTP_USER_AGENT'], $B) && $B['v'] <= 8) {
// Browsers IE 8 and below
} else {
// All other browsers
}
這篇關(guān)于PHP:如果 Internet Explorer 6、7、8 或 9的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!