Simple implementation of PHP Sub-mode (Singleton)

zhaozj2021-02-16  51

Reference

DEVNET and

CHINAUNIX.NET discussions, simply implement the list mode with the following code: Singleton:

code segment:

/ *** Class: SingletonPool * Store Multiple Singletons (Of Different Classes, Natural). ** / Class Singleton {/ ** * Returns a unique object to save multiple objects * * @Param (String) $ Class - The Class Name * @Return Object * @access public * @Static * / Function & GetInstance ($ class) {static $ ob = array (); if (! isset ($ OB [$ Class]) {$ OB [$ Class] = & new $ class;} Return $ OB [$ Class];}}?>

http://www.ooso.net

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

New Post(0)