Created
October 8, 2009 14:08
-
-
Save thefuxia/205045 to your computer and use it in GitHub Desktop.
Template for a singleton.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Description | |
* | |
* Aufruf nur durch | |
<code>{NAME}::getInstance()</code> | |
* @author Thomas Scholz <[email protected]> | |
*/ | |
class {NAME} { | |
/** | |
* @static $instance Objekt | |
* @access private; | |
*/ | |
private static $instance = NULL; | |
private function __construct() | |
{ | |
// Tu was | |
} | |
/** | |
* Verhindert das Klonen des Objektes. | |
*/ | |
private final function __clone() {} | |
public static function getInstance() | |
{ | |
if ( self::$instance === NULL ) | |
{ | |
$class = get_class(); | |
self::$instance = new $class; | |
} | |
return self::$instance; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment