Created
February 24, 2019 10:31
-
-
Save priesdelly/e2ad677efba1dcb4b75f20ce812376d9 to your computer and use it in GitHub Desktop.
Example custom singleton on php
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 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