Re: Accessing child constants from base class
| From: | Ard Biesheuvel | Date: | Fri, 10 Oct 2003 17:33:27 +0000 |
| Subject: | Re: Accessing child constants from base class | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-4783@lists.php.net to get a copy of this message | ||
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();
--
Ard