Created
May 30, 2014 23:29
-
-
Save leviwheatcroft/c18f203a454166c8ad56 to your computer and use it in GitHub Desktop.
just another singleton pattern
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 | |
class Singleton | |
{ | |
protected static $instance = null; | |
protected function __construct() | |
{ | |
} | |
protected function __clone() | |
{ | |
} | |
protected function __wakeup() | |
{ | |
} | |
public static function getInstance() | |
{ | |
if (!isset(static::$instance)) { | |
static::$instance = new static; | |
} | |
return static::$instance; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment