Retrieving class names in a static method
| From: | Adam Bregenzer | Date: | Mon, 02 Feb 2004 20:32:56 +0000 |
| Subject: | Retrieving class names in a static method | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-176613@lists.php.net to get a copy of this message | ||
I'm looking for a way to find the class name of an object within a
static method. class_name($this) works for instances, but in a static
method $this does not exist. Also, __CLASS__ isn't inheritable so isn't
really a solution for what I am looking for. Has anybody done this
before?
Here's a theoretical example:
class Foo {
function getClassName() {
// ???
}
}
class Bar extends Foo {
}
echo Foo::getClassName(); // returns 'foo'
echo Bar::getClassName(); // returns 'bar'
One sample application of this would be a debugging method in a base
class that is inherited and used in a static method.
TIA,
Adam
--
Adam Bregenzer
adam@bregenzer.net