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();
?>
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();
?>
人生有许多的选择,Flash+php企业级系统开发就是我的梦想

浙公网安备 33010602011771号