Re: Object Inheritance, get_class() and a static function call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello axel,

Tuesday, July 26, 2005, 8:02:05 PM, you wrote:

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

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

"The double colon, is a token that allows access to static, constant,
and overridden members or methods of a class."

Of which none of yours are (at least not in the code posted)

Wouldn't get_parent_class() work in this situation?

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux