/**
* 判断浏览器名称和版本
*/
function get_user_browser()
{
if (empty($_SERVER['HTTP_USER_AGENT']))
{
return '';
}
$agent = $_SERVER['HTTP_USER_AGENT'];
$browser = '';
$browser_ver = '';
if (preg_match('/MSIE\s([^\s|;]+)/i', $agent, $regs))
{
$browser = 'Internet Explorer';
$browser_ver = $regs[1];
}
elseif (preg_match('/FireFox\/([^\s]+)/i', $agent, $regs))
{
$browser = 'FireFox';
$browser_ver = $regs[1];
}
elseif (preg_match('/Maxthon/i', $agent, $regs))
{
$browser = '(Internet Explorer ' .$browser_ver. ') Maxthon';
$browser_ver = '';
}
elseif (preg_match('/Opera[\s|\/]([^\s]+)/i', $agent, $regs))
{
$browser = 'Opera';
$browser_ver = $regs[1];
}
elseif (preg_match('/OmniWeb\/(v*)([^\s|;]+)/i', $agent, $regs))
{
$browser = 'OmniWeb';
$browser_ver = $regs[2];
}
elseif (preg_match('/Netscape([\d]*)\/([^\s]+)/i', $agent, $regs))
{
$browser = 'Netscape';
$browser_ver = $regs[2];
}
elseif (preg_match('/safari\/([^\s]+)/i', $agent, $regs))
{
$browser = 'Safari';
$browser_ver = $regs[1];
}
elseif (preg_match('/NetCaptor\s([^\s|;]+)/i', $agent, $regs))
{
$browser = '(Internet Explorer ' .$browser_ver. ') NetCaptor';
$browser_ver = $regs[1];
}
elseif (preg_match('/Lynx\/([^\s]+)/i', $agent, $regs))
{
$browser = 'Lynx';
$browser_ver = $regs[1];
}
if (!empty($browser))
{
return addslashes($browser . ' ' . $browser_ver);
}
else
{
return 'Unknow browser';
}
}
function my_get_browser(){
if(empty($_SERVER['HTTP_USER_AGENT'])){
return 'robot!';
}
if( (false == strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident')!==FALSE) ){
return 'Internet Explorer 11.0';
}
if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 10.0')){
return 'Internet Explorer 10.0';
}
if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 9.0')){
return 'Internet Explorer 9.0';
}
if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 8.0')){
return 'Internet Explorer 8.0';
}
if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 7.0')){
return 'Internet Explorer 7.0';
}
if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 6.0')){
return 'Internet Explorer 6.0';
}
if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'Edge')){
return 'Edge';
}
if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'Firefox')){
return 'Firefox';
}
if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'Chrome')){
return 'Chrome';
}
if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'Safari')){
return 'Safari';
}
if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'Opera')){
return 'Opera';
}
if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'360SE')){
return '360SE';
}
//微信浏览器
if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'MicroMessage')){
return 'MicroMessage';
}
}