Find out which class called a method in another class

后端 未结 8 2104
时光说笑
时光说笑 2020-11-27 06:10

Is there a way in PHP to find out what object called what method in another object.

Exmaple:

class Foo
{
  public function __construct()
  {
    $bar         


        
8条回答
  •  春和景丽
    2020-11-27 06:37

    You can probably achieve this with a debug backtrace, though this seems kind of hackish.

    Your alternative option is to pass a parameter to that class and tell it where it is being called from, when you instantiate the class from within another.

提交回复
热议问题