当前位置:Gxlcms > PHP教程 > php中的设计模式之策略模式

php中的设计模式之策略模式

时间:2021-07-01 10:21:17 帮助过:22人阅读

strategy = $strategy;	}		// 开始策略	public function startStrategy(){		$this->strategy->handle(); 	}	}$people = 'teacher';switch($people){	case 'student' : $strategy = new studentStrategy () ;break;	case 'teacher' : $strategy = new teacherStrategy () ;break;}$safePeople = new TestCheck();$safePeople ->setStrategy($strategy);$safePeople ->startStrategy();

人气教程排行