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; }
时间: 2024-10-17 01:56:45