【php】 检测 ie ie11 edge浏览器

来源 php.net 官网评论截取

-- Declan kelly

Please note that Internet Explorer 11 no longer contains MSIE in its user agent string, for example on Windows 8 with IE11 I get the following:

Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko

So if you want to include a test for IE11, the code above changes to: 

<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE ||
    strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== FALSE) {
    echo 'You are using Internet Explorer.<br />';
}
?>

-- Bilal.S

On Edge, the user agent string does not contain 'MSIE' neither 'Trident', but rather 'Edge'.

猜你喜欢

转载自www.cnblogs.com/china-flint/p/9582592.html