Return to Snippet

Revision: 5089
at February 11, 2008 09:43 by cyrilbatillat


Initial Code
<?php
Class Single {
   static $instance;

   private function __construct() {}

   static function GetInstance() {
      if (empty(self::$MyInstance)) self::$MyInstance = new Single;  
      return self::$MyInstance;
   }

}
?>

Initial URL

                                

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

Initial Title
Singleton class

Initial Tags

                                

Initial Language
PHP