Singleton.php 364 B

12345678910111213141516171819202122
  1. <?php
  2. class Singleton
  3. {
  4. private static $uniqueInstance = null;
  5. protected function __construct()
  6. {
  7. }
  8. final private function __clone()
  9. {
  10. }
  11. public static function getInstance()
  12. {
  13. if (self::$uniqueInstance === null) {
  14. self::$uniqueInstance = new self;
  15. }
  16. return self::$uniqueInstance;
  17. }
  18. }