Find out which class called a method in another class

后端 未结 8 2137
时光说笑
时光说笑 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条回答
  •  旧时难觅i
    2020-11-27 06:35

    var_dump(getClass($this)); 
    

    Used in a method in namespace B this will give you the class that called a method in namespace B from namespace A.

提交回复
热议问题