note 65755 deleted from language.oop5.patterns by felipe

From: Date: Sat, 15 Dec 2007 01:46:20 +0000
Subject: note 65755 deleted from language.oop5.patterns by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133511@lists.php.net to get a copy of this message
Note Submitter: ---- I have founded an additional way to use singleton, which made the __CLASS__ define in this function unneeded. Just by using new self; Im not sure if this is reducing the parsetime. <?php class Example { private static $instance; public static function getInstance() { if (!isset (self::$instance)) { self::$instance = new self; } return self::$instance; } public function printString() { return "I need to be printed."; } } $foo = Example::getInstance(); print $foo->printString(); ?>

« previous php.notes (#133511) next »