今更って感じですが。
<?php class Foo { /** * @brief * @param * @retval */ static function getSingleton() { static $cache ; if (is_null($cache)){ $cache = new static(); } return $cache; } /** * @brief * @param * @retval */ function whoisme() { return get_class($this); } } class A extends Foo { } class B extends Foo { } $a = A::getSingleton(); var_dump($a->whoisme()); $b = B::getSingleton(); var_dump($b->whoisme()); $c = A::getSingleton(); var_dump($c->whoisme()); $d = A::getSingleton(); var_dump($d->whoisme());
で、$c/$dは$aと同じクラスA。$bはクラスB