Skip to content

Instantly share code, notes, and snippets.

@lishiyo
Created April 12, 2015 04:38
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 lishiyo/ef0ccc518835abc57c86 to your computer and use it in GitHub Desktop.
Save lishiyo/ef0ccc518835abc57c86 to your computer and use it in GitHub Desktop.
PHP Examples - Singleton
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