Skip to content

Instantly share code, notes, and snippets.

@shroukkhan
Created July 9, 2013 01:28
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 shroukkhan/5953929 to your computer and use it in GitHub Desktop.
Save shroukkhan/5953929 to your computer and use it in GitHub Desktop.
php create class instance
/*******************************************************/
protected static $instance = null;
protected function __construct()
{
//Thou shalt not construct that which is unconstructable!
}
protected function __clone()
{
//Me not like clones! Me smash clones!
}
public static function getInstance()
{
if (!isset(static::$instance)) {
static::$instance = new static;
}
return static::$instance;
}
/*********************************************************/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment