<?php
class Singleton {
private static $instance;
private function __construct(){ /* ... @return Singleton */ }
private function __clone() { /* ... @return Singleton */ }
private function __wakeup() { /* ... @return Singleton */ }
public static function getInstance() {
if ( empty(self::$instance) ) {
self::$instance = new self();
}
return self::$instance;
}
public function doAction() { /* ... */ }
}
Singleton::getInstance()->doAction(); // Применение
?>
Вот, обновил немного jsfiddle.net/2976n/3