note 49463 added to language.oop5.patterns

From: Date: Fri, 28 Jan 2005 19:45:12 +0000
Subject: note 49463 added to language.oop5.patterns
Groups: php.notes 
Request: Send a blank email to php-notes+get-84137@lists.php.net to get a copy of this message
If you are going to implement the Singleton Pattern you don't want to forget the magic __clone method. class Singleton { private static $singleton; private function __construct() { echo "inside constructor method."; } public static function getInstance() { if (self::$singleton == null) { self::$singleton = new Singleton; } return self::$singleton; } public function __clone() { trigger_error('Clone is not allowed.', E_USER_ERROR); } } $instance1 = Singleton::getInstance(); $instance2 = Singleton::getIntance(); $instance3 = clone($instance1); ---- Manual Page -- http://www.php.net/manual/en/language.oop5.patterns.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49463 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49463&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49463&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49463&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49463&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49463&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49463&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84137) next »