Skip to content

Instantly share code, notes, and snippets.

@kokx
Created April 1, 2011 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kokx/898726 to your computer and use it in GitHub Desktop.
Save kokx/898726 to your computer and use it in GitHub Desktop.
<?php
// you simply call this with Singleton::getInstance()
class Singleton
{
private static $instance;
private function __construct()
{}
public static function getInstance()
{
if (null === 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