php判断浏览器是不是IE

1、$_SERVER['HTTP_USER_AGENT']和strpos

 

2、打印结果

谷歌:
 "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36"

火狐:
 "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0" 

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

  

3、php控制器中

网上说用判断ua中是否有MSIE,然而并没有,用Triden判断也可以的。

public function isIE() { 
	$isIE = strpos($_SERVER['HTTP_USER_AGENT'],"Triden");
	return $isIE;	
}

  

4、在线检测

http://www.966266.com/ua-test/ua.php

 

posted @ 2017-06-16 20:35  leaf+  阅读(4299)  评论(0编辑  收藏  举报