In PHP is it possible to identify the name of the variable containing the object? For example:
class Foo {
public function IdentifyContainer() {
//PHP to identify variable containing Foo.
}
}
$bar = new Foo();
echo $bar->IdentifyContainer(); // This should echo "bar";
I have no idea if this can be done or not, but it would really help me if it can as I have 4 instances of the same class being called on a single page load and I'm trying to identify them all.
EDIT
I should have originally mentioned this is purely for debugging. debug_backtrace
worked for me. Thanks to everyone who suggested it :).