|
- //返回浏览器版本
- 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];
- }
复制代码 |
|