SingleTon::getInstance();
SingleTon::getInstance();
SingleTon::getInstance();
class SingleTon{
private static $instance;
public function __clone(){
}
protected function __construct(){
}
public static function getInstance(){
if( ! self::$instance || !(self::$instance instanceof SingleTon) ){
self::$instance = new self();
echo 'this is a new instance.' . PHP_EOL;
}else{
echo 'this is a old instance.' . PHP_EOL;
}
return self::$instance;
}
}