Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 30th, 2012  |  syntax: None  |  size: 0.32 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. class Singleton
  4. {
  5.     static public function getSingleton()
  6.     {
  7.         static $object;
  8.  
  9.         if (!isset($object)) {
  10.             $object = new Singleton();
  11.         }
  12.         return $object;
  13.     }
  14.  
  15.     private function __construct()
  16.     {
  17.     }
  18.  
  19.     private function __clone()
  20.     {
  21.     }
  22. }
  23. ?>