PHP: If internet explorer 6, 7, 8 , or 9(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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP:如果 Internet Explorer 6、7、8 或 9


- SoapClient 设置自定义 HTTP Header 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- Laravel 仓库 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01