note 96556 deleted from language.oop5.constants by danbrown
| From: | danbrown@php.net | Date: | Wed, 03 Aug 2011 13:28:14 +0000 |
| Subject: | note 96556 deleted from language.oop5.constants by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-182173@lists.php.net to get a copy of this message | ||
Note Submitter: narwhal dot jury at gmail dot com
----
It's worth noting that with v5.3, the problem mentioned a few times in these notes of
referencing a childs const within a parent is solved!
<?php
class MyClass {
const MY_CONST = "yonder";
public function __construct() {
$c = get_class( $this );
echo $c::MY_CONST;
}
}
class ChildClass extends MyClass {
const MY_CONST = "bar";
}
$x = new ChildClass(); // prints 'bar'
$y = new MyClass(); // prints 'yonder'
?>
RJ