class singleton { private static $instance = null; private function singleton() { } public static function &getInstance() { if(is_null(self::$instance)) self::$instance = new self(); return self::$instance; } public function __destruct() { } public function __clone() { trigger_error('Cloning instances of this class is forbidden.', E_USER_ERROR); } public function __wakeup() { trigger_error('Unserializing instances of this class is forbidden.', E_USER_ERROR); } }