Skip to content

Instantly share code, notes, and snippets.

@nickrouty
Created April 1, 2017 18:01
Show Gist options
  • Save nickrouty/bb13ac713746079c16ec45ff56e86e2b to your computer and use it in GitHub Desktop.
Save nickrouty/bb13ac713746079c16ec45ff56e86e2b to your computer and use it in GitHub Desktop.
Example Singleton
class ExampleSingleton {
private $properties = array();
private static $instance;
private __construct(){}
public getInstance()
{
if (empty(self::$instance)) {
self::$instance = new ExampleSingleton();
}
return self::$instance;
}
public function setProperty($key, $value)
{
$this->properties[$key] = $value;
}
public function getProperty($key)
{
return $this->properties[$key];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment