<?php /** **策略模式:定义一系列算法,使他们可相互替换,并且算法的改变不影响使用他们的客户 *******/ interface strategy{ public function filter(); } class User implements strategy{ public function filter(){ echo ‘user filter‘; } } class Enery implements strategy{ public function filter(){ echo ‘enery filter‘; } } class Client{ public function main(){ $User = new User(); $User->filter(); } }
时间: 2024-12-28 12:15:05