PHP 设计模式-工厂模式
程序员文章站
2024-01-21 20:35:04
...
基本概念:工厂方法或者类生成对象,不在代码中直接new#####
原始写法:
index.php$db = new Database();
工厂模式:
index.php
$db = Database::create();`
Factory.php
class Factory
{
static function create(){
$db = new Database();
return $db;
}
}
上一篇: java反射
下一篇: 谈谈那些年微信支付踩过的坑