We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


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.