note 96419 deleted from function.get-class by danbrown

From: Date: Fri, 26 Feb 2010 19:26:09 +0000
Subject: note 96419 deleted from function.get-class by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-166412@lists.php.net to get a copy of this message
Note Submitter: eizdealer at no dot spam dot org ---- Regarding the Singleton base class posted by danbettles: I think the following solution is cleaner and more obvious. <?php class HS_Singleton { protected static $instance; protected function __construct() { } final private function __clone() { } final public static function get_instance() { if (self::$instance===null) { $child_class = get_called_class(); self::$instance = new $child_class; } return self::$instance; } } ?>

« previous php.notes (#166412) next »