访问父构造函数

时间:2016-03-11 23:06:25

标签: php oop namespaces

我在不同的命名空间中有子类,而不是它的父抽象类 在子类构造方法中看起来像这样:

namespace someNameSpace;

class childClass extends \parentClass

    function __construct()
        {
            parent::__construct();
        }
在父类构造函数中的

我应该在子命名空间中调用另一个类方法。 像这样:

abstract class parentClass

function __construct()
{
    somenameSpace\anotherChildClass::method();
}

问题:我不能只写 somenameSpace \ anotherChildClass 因为我在不同的命名空间中有很多子类,而命名空间应该是动态的。

如果我只写 anotherChildClass :: method(); 我找不到类错误,因为它在父命名空间中执行。我怎么能解决这个问题?

0 个答案:

没有答案