Re: Singletons
| From: | n3or | Date: | Mon, 20 Oct 2008 18:13:29 +0000 |
| Subject: | Re: Singletons | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-282139@lists.php.net to get a copy of this message | ||
Christoph Boget schrieb:
it avoids cloning of the object: $newObject = clone $oldObject; -- Viele Gruessee Dominik Strauss - www.n3or.de Webentwicklung, PHP und Linux Mobil: 0178 4940605 Internet: www.n3or.de E-Mail: info@n3or.deAdding the above to my sample class (from my OP) did nothing. Should it have? thnx, Christoph Hi,Apart from making the constructor private, is there any way I can ensure that there is ever only one instance of an object?you could use the magic method __clone. For example: public function __clone() { trigger_error('The singleton pattern avoids cloning this instance', E_USER_ERROR); }