PHP Classes

singleton pattern

Recommend this page to a friend!

      PHP Classes blog  >  What Are PHP Classes ...  >  All threads  >  singleton pattern  >  (Un) Subscribe thread alerts  
Subject:singleton pattern
Summary:also it is very usefull singleton for configuration
Messages:2
Author:Daniele Cruciani
Date:2012-03-22 09:00:19
Update:2012-03-22 23:38:27
 

  1. singleton pattern   Reply   Report abuse  
Picture of Daniele Cruciani Daniele Cruciani - 2012-03-22 12:38:03
Configuration or db connect could be implemented with singleton pattern, for example
$cfg = CONFIG::getInstance();
$cfg->setValue(2);
also making a __destruct that write config back in db, and so .. there a lot of clever idiomas that can be implemented with oop

  2. Re: singleton pattern   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2012-03-22 23:38:27 - In reply to message 1 from Daniele Cruciani
Right, that is yet another thing about OOP, that despite useful, it was not in the scope of this article.