本文介紹了PHP:如果 Internet Explorer 6、7、8 或 9的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我想在 PHP 中為不同版本的 Internet Explorer 執行以下操作:
I want to do a conditional in PHP for the different versions of Internet Explorer along the lines of:
if($browser == ie6){//做這個} elseif($browser == ie7) {//做這個 } elseif...
我已經看到類似代碼的許多變體,但正在尋找一些非常簡單的代碼來執行一些簡單的 if 和 else 并執行不同的操作.
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.
謝謝
我需要這個來向用戶顯示一些不同的消息,所以 CSS 條件等不好.
I need this to show some different messages to users so CSS conditionals etc are no good.
推薦答案
這是我最終使用的一個變體,它檢查 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
}
這篇關于PHP:如果 Internet Explorer 6、7、8 或 9的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!