<?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();
?>
转载于:https://www.cnblogs.com/chenyuanfeng/archive/2011/05/10/2041786.html