Skip to content

Instantly share code, notes, and snippets.

@lgedeon
Created May 22, 2018 19:35
Show Gist options
  • Save lgedeon/74c313540be399d322b2bd80add1ab8f to your computer and use it in GitHub Desktop.
Save lgedeon/74c313540be399d322b2bd80add1ab8f to your computer and use it in GitHub Desktop.
<?php
class Singlton {
// Singlton instance.
static $instance = null;
// Do not create multiples.
private function __construct() {
}
/**
* Return singlton instance. Create if necessary.
*
* @return Singlton
*/
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new Singlton();
}
return self::$instance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment