php中策略模式中浏览器判定

<?php
abstract class baseAgent{
abstract function PrintPage();
}
class ieAgent extends baseAgent{
function PrintPage(){
return "当前浏览器是IE!";
}
}
class otherAgent extends baseAgent{
function PrintPage(){
return "当前浏览器不是IE!";
}
}
if(strstr($_SERVER["HTTP_USER_AGENT"],"IEAGENT"))
{
$currPage=new ieAgent();
}
else{
$currPage=new otherAgent();
}
echo $currPage->PrintPage();
?>

posted @ 2011-05-10 08:50  乐享Flash&PHP  阅读(232)  评论(0)    收藏  举报