命令模式
命令類
作用
<?php
//命令接口
interface Command{
public function execute();
}
//具體命令
class ConcreteCommand implements Command{
private $_receiver;
public function __construct($receiver){
$this
}
public function execute(){
$this
}
}
//接受者
class Receiver{
private $_name;
public function __construct($name){
$this
}
//行動方法
public function action(){
echo $this
}
}
//請求者
class Invoker{
private $_command;
public function __construct($command){
$this
}
public function action(){
$this
}
}
//客戶端
class Client{
public static function main(){
$receiver = new Receiver(
$command = new ConcreteeCommand($receiver);
$invoker = new Invoker($command);
$invoker
}
}
Client::main();
?>
From:http://tw.wingwit.com/Article/program/PHP/201311/21232.html