Created
July 9, 2013 01:28
-
-
Save shroukkhan/5953929 to your computer and use it in GitHub Desktop.
php create class instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*******************************************************/ | |
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