All pastes #403385 Raw Edit

Ox41464b

public php v1 · immutable
·published 2007-03-20 10:10 UTC
rendered paste body
<?phpclass Singleton{    function &getInstance()    //PHP4 style Singleton reference    {        static $_instance;        if (!isset($_instance))        {            //--------- Problem Goes here ---------//            $className = __CLASS__;       //this one return String "Singleton"            $className = get_class();     //also Singleton            $className = get_class($this);//undefined $this            $className = get_class(self); //undefined self            //------------------------------------//            $_instance = new $className;        }        return $_instance;    }}class foo extends Singleton {}$obj = foo::getInstance();/*Question:How do i get child class from inside parentClass function*/?>