Discuz browserversion函数 检测浏览器版本
xiao9469
2023/10/24 15:00:39
- //返回浏览器版本function browserversion($type) { static $return = array(); static $types = array('ie' => 'msie', 'firefox' => '', 'chrome' => '', 'opera' => '', 'safari' => '', 'mozilla' => '', 'webkit' => '', 'maxthon' => '', 'qq' => 'qqbrowser'); if(!$return) { $useragent = strtolower($_SERVER['HTTP_USER_AGENT']); $other = 1; foreach($types as $i => $v) { $v = $v ? $v : $i; if(strpos($useragent, $v) !== false) { preg_match('/'.$v.'(\/|\s)([\d\.]+)/i', $useragent, $matches); $ver = $matches[2]; $other = $ver !== 0 && $v != 'mozilla' ? 0 : $other; } else { $ver = 0; } $return[$i] = $ver; } $return['other'] = $other; } return $return[$type];}