Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Singleton
- {
- private static $instance = null;
- private $id=1;
- public static function getInstance()
- {
- if (null === self::$instance)
- {
- self::$instance = new self();
- }
- return self::$instance;
- }
- private function __clone() {}
- private function __construct() {}
- public function myId()
- {
- return $this->id;
- }
- }
- $Object = Singleton::getInstance(); // Получение объекта
- $Object -> myId();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement