PHP设计模式-简单工厂模式
作者:互联网
<?php class american{ public function talk(){ echo 'english'; } public function skin(){ echo 'while'; } } class chiness{ public function talk(){ echo '汉语汉语'; } public function skin(){ echo '黄色'; } } class controll{ public function anser($people){ switch($people){ case 'chiness': return new chiness(); case 'american': return new american(); default: return null; } } } $obj = new controll(); $chiness = $obj->anser('chiness'); $chiness->talk(); $chiness->skin(); ?>
标签:PHP,工厂,chiness,skin,设计模式,anser,talk 来源: https://www.cnblogs.com/qutao125/p/14607641.html