判断用户浏览器的类型
/** * 判断用户浏览器的类型 * @param mixed $agent HTTP_USER_AGENT */ public static function getBrowserType($agent = null) { $agent = null !== $agent ? $agent : strtolower($_SERVER['HTTP_USER_AGENT']); $strs = [ 'msie' => 'ie', 'edge' => 'edge', 'firefox' => 'firefox', 'chrome' => 'chrome', 'safari' => 'safari', 'opera' => 'opera', 'omniweb' => 'omniweb', 'netscape' => 'netscape', 'micromessage' => 'wechat', ]; foreach ($strs as $k => $v) { if (strpos($agent, $k) !== false) { return $v; } } return 'unkown'; }
发表评论