public static function main(array $args = array()) { $boiler = ChocolateBoiler::getInstance(); $boiler->fill(); $boiler->boil(); $boiler->drain(); // will return the existing instance $boiler2 = ChocolateBoiler::getInstance(); }
public static function getInstance() { if (self::$uniqueInstance == NULL) { println("Creating unique instance of Chocolate Boiler"); self::$uniqueInstance = new ChocolateBoiler(); } println("Returning instance of Chocolate Boiler"); return self::$uniqueInstance; }