<?php
/**
* Example
*/
include "MSingleton.php";
/**
* class Singleton
*
* Example child of singleton factory
*
* Notice:
* If call test method twice, Singleton __construct
* must be called once, and test method twice
* output must be: * Construct called * * test called * * test called *
*
*/
class Singleton extends MSingleton {
protected function __construct() {
echo " * Construct called *", PHP_EOL;
}
protected function __clone() {}
public function test() {
echo " * test called * ";
}
}
Singleton::getInstance()->test();
Singleton::getInstance()->test();
|