{
// 具体策略角色C
public function do_method()
{
echo 'do method 3';
}
}
class Question
{
// 环境角色
private $_strategy;
public function __construct(Strategy $strategy)
{
$this->_strategy = $strategy;
}
public function handle_question()
{
$this->_strategy->do_method();
}
}
// client
$strategyA = new ConcreteStrategyA();
$question = new Question($strategyA);
$question->handle_question();
$strategyB = new ConcreteStrategyB();
$question = new Question($strategyB);
$question->handle_question();
$strategyC = new ConcreteStrategyC();
$question = new Question($strategyC);
$question->handle_question();