Posted By

px on 08/01/06


Tagged

pattern php5 Singleton


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

px
vaaaska
fernandojmartin
Priestd09


PHP5 Singleton pattern


 / Published in: PHP
 

URL: http://simplex.pp.ru/tech/php/singleton

  1. class SampleClass{
  2. static private $instance = false;
  3.  
  4. function getInstance(){
  5. if (!self::$instance){
  6. self::$instance = new SampleClass();
  7. }
  8. return self::$instance;
  9. }
  10. }
  11.  
  12. //Usage
  13. $SampleClassObject = SampleClass::getInstance();

Report this snippet  

You need to login to post a comment.