Created
December 4, 2014 17:05
-
-
Save aklesky/af63ac88c8b59adf00dc to your computer and use it in GitHub Desktop.
PHP Singletone
This file contains hidden or 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
| <?php | |
| static public function getInstance() | |
| { | |
| static $instance; | |
| $class = get_called_class(); | |
| if (!($instance instanceof $class)) { | |
| $reflection = new \ReflectionClass($class); | |
| $instance = $reflection->newInstanceArgs(func_get_args()); | |
| } | |
| return $instance; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment