策略模式多算法独立于客户端变化con_strategy=$concrete_strategy;}publicfunctionhandle(){$this->con_strategy->totalMethod();}}//主程序尝试{$context_a=newContext(newStrategyA());$context_a->handle();$context_b=newContext(newStrategyB());$context_b->handle();$context_c=newContext(newStrategyC());$context_c->handle();}catch(Exception$e){echo$e->getMessage();}
