20 lines
414 B
PHP
20 lines
414 B
PHP
<?php
|
|
|
|
abstract class Singleton {
|
|
|
|
protected function __construct() {}
|
|
|
|
final public static function getInstance() {
|
|
static $_instances = array();
|
|
|
|
$class_name = get_called_class();
|
|
|
|
if (! isset($_instances[$class_name])) {
|
|
$_instances[$class_name] = new $class_name();
|
|
}
|
|
|
|
return $_instances[$class_name];
|
|
}
|
|
|
|
final private function __clone() {}
|
|
} |