Skip to content

Instantly share code, notes, and snippets.

@priesdelly
Created February 24, 2019 10:31
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 priesdelly/e2ad677efba1dcb4b75f20ce812376d9 to your computer and use it in GitHub Desktop.
Save priesdelly/e2ad677efba1dcb4b75f20ce812376d9 to your computer and use it in GitHub Desktop.
Example custom singleton on php
class SampleSingleton
{
private static $_instance = null;
private function __construct()
{
}
public function getInstance()
{
if (!(self::$_instance instanceof SampleSingleton)) {
self::$_instance = new SampleSingleton();
}
return self::$_instance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment