<?php
class SingletonSample
{
private $_id;
private static $_instance;
private function __construct()
{
$this->_id = md5(date('r') . mt_rand());
}
public static function getInstance()
{
if (!isset(self::$_instance)) {
self::$_instance = new SingletonSample();
echo 'SingletonSample instance was created.';
}
return self::$_instance;
}
public function getId()
{
return $this->_id;
}
public final function __clone()
{
throw new LogicException('Clone is not allowed against [' . get_class($this) . '].');
}
}