Created
October 6, 2017 14:30
-
-
Save seriiserii825/a13fe3fabfad71f539e58de0fa5654bf to your computer and use it in GitHub Desktop.
singleton
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
class Singleton | |
{ | |
protected static $instance; | |
protected function __construct() | |
{ | |
} | |
public static function instance() | |
{ | |
if (null === 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