Ale*_*ome 15 php inheritance static
我们有一个代码
class ParentClass {
public static function getName() {
return get_class(self);
}
}
class ChildClass extends ParentClass {
}
echo ParentClass::getName(); # => 'ParentClass'
echo ChildClass::getName(); # => 'ParentClass'
Run Code Online (Sandbox Code Playgroud)
如果我使用get_class($ this),则会得到相同的结果.也适用于self :: $ this,static :: $ this等
有没有为子类添加方法而获取子类名的任何方法?