Skip to content

Instantly share code, notes, and snippets.

@Bouke
Created August 16, 2010 09:39
Show Gist options
  • Select an option

  • Save Bouke/526703 to your computer and use it in GitHub Desktop.

Select an option

Save Bouke/526703 to your computer and use it in GitHub Desktop.
Singleton Snippet
class ${ClassName} {
protected static $instance;
/**
* Returns an instance of this Singleton
* @return ${ClassName}
*/
public static function getInstance() {
if(!isset(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
protected function __construct() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment