作者 e6nian [php] 2008-01-30 14:11 (点击下载)

  1. class Singleton
  2. {
  3. // Single instance of class available.
  4. static private $instances= array();
  5. /**
  6. * Returns the single shared static instance variable
  7. * which facilitates the Singleton pattern
  8. *
  9. * @note each subclass should implement an instance() method which
  10. * passes the class name to the parent::instance() function
  11. * @return object instance
  12. */
  13. static protected function instance( $class )
  14. {
  15. if ( ! isset( self::$instances[$class] ) ) {
  16. self::$instances[$class]= new $class();
  17. }
  18. return self::$instances[$class];
  19. }
  20.  
  21. /** Prevent instance construction and cloning (copying of object instance) */
  22. protected final function __construct() {}
  23. private final function __clone() {}
  24. }

提交下面的校正或者修改. (点击这里开始一个新的帖子)
姓名: 在 cookie 中记住我的名字

屏幕抓图:(jpeg 或 png)