设计模式
ghostyusheng
God build us in his image. Now it is the time to make the real AI in our image!
展开
-
php装饰者模式
装饰者模式动态地将责任附加到对象上,若要扩展功能,装饰者提供了比继承更有弹性的替代方案.example code:# Beverage.php<?phpnamespace Strategy;abstract class Beverage{ public $description = 'Unknown Drink'; public function ge原创 2017-02-22 15:30:15 · 364 阅读 · 0 评论 -
php设计模式_简单工厂2
<?phpclass ChinaPizzaA { public function __construct () { print_r('create ChinaPizzaA instance'); } public function cook () { print_r('cooking ChinaA pizza!'); }原创 2017-07-11 18:28:43 · 301 阅读 · 0 评论 -
php设计模式_简单工厂
<?phpclass PizzaA { public function __construct () { print_r('create PizzaA instance'); } public function cook () { print_r('cooking pizza!'); } public f原创 2017-07-11 17:54:20 · 266 阅读 · 0 评论 -
php设计模式_单例模式
<?phpclass Aaa { private static $me; public static function getInstance () { if (!Aaa::$me) { print_r('single instance'); return new Aaa(); }原创 2017-07-12 11:47:47 · 205 阅读 · 0 评论 -
php设计模式_命令模式
<?phprequire 'Light.php';class LightA extends Light { public function __construct () { print_r("create a lightA "); } public function on () { print_r('lightA is on'原创 2017-07-12 13:58:50 · 279 阅读 · 0 评论