Getting the name of the Class
| From: | Lasse Cederström | Date: | Wed, 26 May 2004 12:23:08 +0000 |
| Subject: | Getting the name of the Class | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-186985@lists.php.net to get a copy of this message | ||
Hello!
I have a problem that I hope someone can solve for me ;-)
I have two classes:
Class Test
{
Function Test()
{
print(Hello Test);
}
}
Class MyClass extends Test
{
Function Debug()
{
print(Hello MyClass);
}
}
From my code I would like to make the following call: MyClass::Test(); -
This will obvious output Hello Test. But in the function Test::Test is
there anyway to know that MyClass::Test was called? I would like to get the
MyClass in a string, somehow. If other classes extended Test, it would be
that classes names.
Keep in mind that I dont have an object to ask, since im just calling it
with MyClass::Test(), so $this will not work :-(
What I tried so far?
__CLASS__ This will return Test since its calling a function in the Test
class and not in MyCalss.
The use of $this not working since im not calling it as an object, but to
the class directly.
Looking forward to someone poking me in the right direction :)
Lasse