Singleton class


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.