Hi Ard-

Sorry, I must of misunderstood you. Yes, that would work
fine. Now copy/paste the getElementName()  function in the
derived class to all 100's of other derived classes and wonder
why you couldn't just do this with one base class function. :)

Dan Cox

Ard Biesheuvel wrote:

This works fine for me:

abstract class Base {

abstract function getElementName();

        function getName()
        {
                return $this->getElementName();
        }
}

class Derived extends Base {

const ElementName = 'DerivedElementName';

        function getElementName()
        {
                return ElementName;
        }
}

$c = new Derived();
echo $c->getName();


-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to