Hello,

following code won't work in the expected way:

class ClassA {
  function getClassName() {
    return get_class($this); # [1]
  }
}
class ClassB extends ClassA { }
echo ClassB::getClassName();

this script echoes "Object" instead of "ClassB". but i would like to return the classname of the derived class without writing the method again.

this will work:

B = new ClassB();
echo ClassB->getClassName();


i tried to use line [2] instead of [1]
  return get_class(self); # [2]
but this only returns an empty string.

is there any solution for my problem?

i'm using PHP Version 5.0.3 (with Apache 1, Windows XP)

greetings
axel

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to