tags:

views:

63

answers:

2

Possible Duplicate:
Find out which class called a method in another class.

Hello everyone,

I have a class and I can't find where his object creates. I mean, can I somehow find out who calls his constructor?

Thanks a lot, Andrey.

+1  A: 

You can use debug_backtrace() or even better a tracer/profiler like Xdebug to gather the information and e.g. KCachegrind to visualize it.

VolkerK
+1  A: 

use

$trace = debug_backtrace();
echo "<pre>".print_r($trace[1])."</pre>"; 
//see all the displays '1' is the referrer '0' is self
echo $callingfunction = $trace[1]['function'];
echo $callingclass = $trace[1]['class'];
Starx