Client 端瀏覽器判斷方式

1 篇文章 / 0 new
author
Client 端瀏覽器判斷方式
if(isset($_SERVER['HTTP_USER_AGENT'])) {
	if(preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT'])) {	}
	elseif(preg_match("/Firefox/", $_SERVER['HTTP_USER_AGENT'])) { }
	elseif(preg_match("/Opera/", $_SERVER['HTTP_USER_AGENT'])) { }
	elseif(preg_match("/Chrome/", $_SERVER['HTTP_USER_AGENT'])) { }
	elseif(preg_match("/Safari/", $_SERVER['HTTP_USER_AGENT'])) { 					
		if(preg_match("/Version\/[0-3]./", $browser)) {//版本判斷方式
			//Safari 3.x & before
		}else{
			//Safari 4.x & after				
		}
	}else{
		//其他瀏覽器
	}
} else { /*沒有瀏覽器資訊*/ }

 

Free Web Hosting