Skip to content

Instantly share code, notes, and snippets.

@DavidHernandez
Created January 16, 2015 10:15
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 DavidHernandez/a2bb5639868986ff267e to your computer and use it in GitHub Desktop.
Save DavidHernandez/a2bb5639868986ff267e to your computer and use it in GitHub Desktop.
Maybe another singleton implementation
<?php
/**
* @file
* Contains Singleton.
*/
/**
* Singleton that gets saved into a global variable.
*/
class Singleton {
private static $instance;
public function __construct() {
if (!isset($instance)) {
$this->instance = new static();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment