note 68591 added to language.oop5.patterns
| From: | daniel at basegeo dot com | Date: | Wed, 02 Aug 2006 19:55:59 +0000 |
| Subject: | note 68591 added to language.oop5.patterns | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115493@lists.php.net to get a copy of this message | ||
Ubaldo, you cannot expect to get the same instance using the Singleton pattern on different runs of
the script.
Each time you execute index.php it's a new runtime environment. It's like executing
several times Notepad, each run is unrelated to the others.
As your scripts grow in size, and you modularize code used on many pages into classes and libraries
you'll realize how useful the Singleton pattern is. For instance, you can create a database
abstraction class that you can call from many places and always be asured it's a single
instance... in this case that means a single connection to the database.
Hope this clarifies the issue for you.
----
Server IP: 66.163.161.117
Probable Submitter: 84.94.97.5 (proxied: 84.94.97.5)
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/language.oop5.patterns.php
Edit -- https://master.php.net/note/edit/68591
Del: integrated -- https://master.php.net/note/delete/68591/integrated
Del: useless -- https://master.php.net/note/delete/68591/useless
Del: bad code -- https://master.php.net/note/delete/68591/bad+code
Del: spam -- https://master.php.net/note/delete/68591/spam
Del: non-english -- https://master.php.net/note/delete/68591/non-english
Del: in docs -- https://master.php.net/note/delete/68591/in+docs
Del: other reasons-- https://master.php.net/note/delete/68591
Reject -- https://master.php.net/note/reject/68591
Search -- https://master.php.net/manage/user-notes.php