继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

php命令模式自我测试

梵蒂冈之花
关注TA
已关注
手记 316
粉丝 30
获赞 169

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');

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

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP