我有一系列使用大量方法重載的繼承類,並且我需要一種方法來找出當它調用特定方法時正在使用哪個類。如何從調用方法獲取類名?
簡單的例子:
class child extends parent
public function _process()
{
$this->_otherrun();
}
public function _run()
class parent extends grandparent
public function _run()
public function _otherrun()
{
// I need to find out which class the version of _run is called in
$this->_run();
}
這個例子很簡單相比,現在我期待通過,所以我需要一種方法來看看其中的類function _run
在被處理的是,即使可能嗎?
事情是這樣的:
get_class(array($this, 'run'));
這不只是這一個修改版本: http://stackoverflow.com/questions/10493720/how-to-get-the-protected-stastic-主要作用範圍內的子範圍/ 10494032#10494032 很明顯,您不需要在構建中使用回顯,並且「get_table_name_protected」將更改爲「_run」。但是......看起來像是你想要的,除非我搞砸了一些東西。 –