Skip to content

Instantly share code, notes, and snippets.

@patrioticcow
Created December 11, 2013 01:02
Show Gist options
  • Save patrioticcow/7903359 to your computer and use it in GitHub Desktop.
Save patrioticcow/7903359 to your computer and use it in GitHub Desktop.
Singleton Pattern
class Logger {
static function getInstance()
{
if (self::$instance == NULL) {
self::$instance = new Logger();
}
return self::$instance;
}
private function __construct()
{
}
private function __clone()
{
}
function Log($str)
{
// Take care of logging
}
static private $instance = NULL;
}
Logger::getInstance()->Log("Checkpoint");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment