<?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(); } }
本文出自 “王尼美的成人之路” 博客,请务必保留此出处http://8335914.blog.51cto.com/8325914/1612458
原文:http://8335914.blog.51cto.com/8325914/1612458