<?php class Singleton { private static $example; private $count = 0; private function __construct() { } public static function single() { return !isset(self::$example) ? self::$example = new self() : self::$example; } public function up() { return $this->count++; } private function __clone() { } } $sin = Singleton::single(); echo $sin->up(); echo $sin->up(); $sin1 = Singleton::single(); echo $sin1->up(); echo $sin1->up();