Created
January 16, 2015 10:15
-
-
Save DavidHernandez/a2bb5639868986ff267e to your computer and use it in GitHub Desktop.
Maybe another singleton implementation
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 | |
/** | |
* @file | |
* Contains Singleton. | |
*/ | |
/** | |
* Singleton that gets saved into a global variable. | |
*/ | |
class Singleton { | |
private static $instance; | |
public function __construct() { | |
if (!isset($instance)) { | |
$this->instance = new static(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment