Aer Interpreter Source
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

32 lines
544 B

final class Test {
private $value;
private function __construct() {
}
/* This is singleton */
public function getInstance() {
static object $instance;
if(!$instance) {
$instance = new Test();
}
return $instance;
}
public function get() {
return $this->value;
}
public function set(int $value = 0) {
$this->value = $value;
}
}
final class Program {
public function main() {
object $testA = Test::getInstance();
$testA->set(5);
object $testB = Test::getInstance();
var_dump($testB->get());
}
} /* class */