class Foo {
function baz() {
echo "How can I tell whether I was called as Foo::baz() or Bar::baz()?";
}
}
class Bar extends Foo {
}
Foo::baz();
Bar::baz();
The reason for this, in case anybody is interested, is so that I can have a single static factory method in a superclass which automatically knows what class of object to create. At the moment I have to do something like:
class Subclass extends Parent {
function create() {
parent::_create(__CLASS__);
}
}
which gets pretty boring after the first five subclasses! Is there a better way?
Dave