<?php
class Foo {
private function __construct() {
$this->t = 'initialized Foo';
}
public $t;
public static function &getFooInstance() {
static $foo_instance;
if( !isset( $foo_instance ) ) {
$foo_instance = &new Foo;
}
return $foo_instance;
}
}
$f = Foo::getFooInstance();
echo $f->t . "\n";
/*
$g = new Foo;
echo $g->t . "\n";
*/
?>
0 件のコメント:
コメントを投稿