note 101112 modified in language.oop5 by danbrown

From: Date: Fri, 26 Nov 2010 16:30:37 +0000
Subject: note 101112 modified in language.oop5 by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174388@lists.php.net to get a copy of this message
With regards to Singleton patterns (and variable class names) - try: <?php class MyClass { // singleton instance private static $instance; // private constructor function // to prevent external instantiation private __construct() { } // getInstance method public static function getInstance() { if(!self::$instance) { self::$instance = new self(); } return self::$instance; } //... } ?> --was-- With regards to Singleton patterns (and variable class names) - try: class MyClass { // singleton instance private static $instance; // private constructor function // to prevent external instantiation private __construct() { } // getInstance method public static function getInstance() { if(!self::$instance) { self::$instance = new self(); } return self::$instance; } ... } http://php.net/manual/en/language.oop5.php

« previous php.notes (#174388) next »