PHP继承方法或父类名称
我将尝试用代码来解释我的问题:PHP继承方法或父类名称,php,oop,inheritance,Php,Oop,Inheritance,我将尝试用代码来解释我的问题: class A extends masterClass { function api() { die(__CLASS__); /* rest of the code here ... */} } class B extends A { /* rest of the code here ... */ } $obj = new B(); $obj->api(); // Should be "B" (name of last child
class A extends masterClass
{
function api()
{
die(__CLASS__);
/* rest of the code here ... */}
}
class B extends A
{
/* rest of the code here ... */
}
$obj = new B();
$obj->api(); // Should be "B" (name of last child class)
有什么“最佳”解决方案吗?
谢谢您可以使用或代替\uuuu CLASS\uuuu