Created
April 12, 2015 04:38
-
-
Save lishiyo/ef0ccc518835abc57c86 to your computer and use it in GitHub Desktop.
PHP Examples - 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 DemoSingleton { | |
private static $instance = NULL; | |
public static function getInstance(){ | |
if(is_null(self::$instance)){ | |
self::$instance = new self(); | |
} | |
return self::$instance; | |
} | |
} | |
$class = DemoSingleton::getInstance(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment