ITPub博客

首页 > IT职业 > IT图书 > php命令模式自我测试

php命令模式自我测试

IT图书 作者:summo 时间:2021-09-09 09:17:51 0 删除 编辑

interface test{

public function Ontest();

}

class caincommand{

private $_command=array();

public function addOrder($command){

$this->_command[]=$command;

}

public function testd($name,$arg){

foreach($this->_command as $a){

if($a->Ontest() == $name){

echo $name;

}

}

}

}

class testDog implements test{

public function Ontest(){

return 'dog';

}

}

class testCat implements test{

public function Ontest(){

return 'cat';

}

}

$dog = new testDog();

$cat = new testCat();

$cain = new caincommand();

$cain->addOrder($dog);

$cain->addOrder($cat);

//$cain->testd('dog','null');

$cain->testd('cat','null');

自己测试的,具体在框架中大家自己体会.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/225/viewspace-2801844/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: Request.php-1
请登录后发表评论 登录
全部评论

注册时间:2020-07-23

  • 博文量
    0
  • 访问量
    929