Implementation of single design patterns in PHP5

xiaoxiao2021-03-05  20

Transfer from: Bo Wang's Weblog

PHP5 in terms of object-oriented strengthening allows us to see the possibility of enterprise applications, many features that cannot be implemented or only don't twist, now I naturally write, the single design pattern requires only one Objects instance, and provide an access point, look at how to implement it in PHP5. Code:

?

Note: Because the constructor is private, it cannot be directly instantiated, and the following method should be used to obtain an example:

$ instance = singleton :: getInstance ();

转载请注明原文地址:https://www.9cbs.com/read-32140.html

New Post(0)