Skip to content

Instantly share code, notes, and snippets.

@ThomasWunderlich
Created February 3, 2013 03:36
Show Gist options
  • Save ThomasWunderlich/4700460 to your computer and use it in GitHub Desktop.
Save ThomasWunderlich/4700460 to your computer and use it in GitHub Desktop.
Singleton pattern
<?php
class SingletonExample
{
static $instance;
private function __construct() {
/*Specific logic for this singleton */
}
public static function getInstance() {
if (!isset(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment