基本概念:工廠方法或者類生成對(duì)象,不在代碼中直接new#####
原始寫法:
index.php
$db = new Database();
工廠模式:
index.php
$db = Database::create();`
Factory.php
class Factory
{
static function create(){
$db = new Database();
return $db;
}
}
基本概念:工廠方法或者類生成對(duì)象,不在代碼中直接new#####
原始寫法:
index.php
$db = new Database();
工廠模式:
index.php
$db = Database::create();`
Factory.php
class Factory
{
static function create(){
$db = new Database();
return $db;
}
}