Posted By

cyrilbatillat on 02/11/08


Tagged

php5


Versions (?)

Singleton class


 / Published in: PHP
 

Usage : $MonObjet = Single::GetInstance();

  1. <?php
  2. Class Single {
  3. static $instance;
  4.  
  5. private function __construct() {}
  6.  
  7. static function GetInstance() {
  8. if (empty(self::$MyInstance)) self::$MyInstance = new Single;
  9. return self::$MyInstance;
  10. }
  11.  
  12. }
  13. ?>

Report this snippet  

You need to login to post a comment.