note 68591 deleted from language.oop5.patterns by danbrown

From: Date: Sun, 23 Jan 2011 16:43:42 +0000
Subject: note 68591 deleted from language.oop5.patterns by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-176116@lists.php.net to get a copy of this message
Note Submitter: daniel at basegeo dot com ---- 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.

« previous php.notes (#176116) next »