我正在开发的 wordpress 主题中设置 IE 检查。我想检查 Internet Explorer 7。所以如果我使用以下代码:
<?php
if (preg_match('/\bmsie 7/i', $ua) && !preg_match('/\bopera/i', $ua))
echo 'Do Something'
?>
代替:
<!--[if lt IE 7]>
Do Something
<![endif]-->
它有什么缺点吗?仅在需要时才尝试加载 HTML。任何见解都值得赞赏。
编辑
发现这篇关于 PHP 方式的非常好的文章:http ://www.kingofdevelopers.com/php-classes/get-browser-name-version.php