PHP design pattern (factory pattern)

Your brother's way of programming (like to share) 2022-02-13 06:07:41 阅读数:789

php design pattern factory pattern


class Factory {

static function createDatabase()

$db=new Factory();
return $db;

The core is : If multiple files create this factory Object words , If you don't use this factory model , It will be modified many times , After using factory mode , Only modify this file once .
 Insert picture description here

copyright:author[Your brother's way of programming (like to share)],Please bring the original link to reprint, thank you.