All pastes #403403 Raw Edit

Miscellany

public php v1 · immutable
·published 2007-03-20 10:35 UTC
rendered paste body
<?phpclass Singleton{    function &getInstance()    //PHP4 style Singleton reference    {        static $_instance;        if (!isset($_instance[$className]))            $_instance[$className] = new $className;        return $_instance[$className];    }}class foo extends Singleton {    function &getInstance()    {        return parent::getInstance(__CLASS__);    }}$obj = foo::getInstance();?>