Multiton code examples of PHP design patterns (4)



Multi instance pattern means that there are multiple instances of the same class, and the instances are the class itself. This class is called a multi instance class. The characteristics of the multiple cases model are as follows

  1. A multi instance class can have multiple instances.

  2. Multi instance classes must create and manage their own instances, and provide their own instances to the outside world.

Multi instance pattern is actually a generalization of single instance pattern.

give an example

  • Two database connectors, such as MySQL and SQLite

  • Multiple recorders (one for debugging messages and one for errors)

UML diagram

Official PHP advanced learning exchange community “click”The management has sorted out some materials, bat and other advanced knowledge systems are ready (relevant learning materials and written questions), and not limited to: distributed architecture, high scalability, high performance, high concurrency, server performance tuning, tp6, laravel, yii2, redis, spool, swoft, Kafka, MySQL optimization, shell script, docker, microservice, nginx and other advanced knowledge points Advanced dry goods


  • Multiton.php

PHP Internet architect’s growth path * “design patterns” Ultimate Guide

PHP Internet architect 50K growth Guide + general outline of industry problem solving (continuous update)

Interview 10 companies, get 9 offers, PHP interview questions in 2020

If you like my article and want to exchange and study with more senior developers, you can get more technical consultation and guidance related to the interview of large factories. Welcome to join usOur group – click here(group number 856460874).

If the content is good, I hope you can support and encourage me to like it, and welcome to communicate with me. In addition, if you have any questions, please put forward the content you want to see in the comments