PHP 继承方法或父 class 名称

PHP inheritance methods or parent class name

我将尝试通过代码在这里解释我的问题:

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)

有什么 'best' 解决方案吗? 谢谢

您可以使用 static::class or get_class($this) 代替 __CLASS__