note 100909 modified in language.oop5.constants by cmb
| From: | cmb@php.net | Date: | Wed, 31 Aug 2016 17:37:25 +0000 |
| Subject: | note 100909 modified in language.oop5.constants by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-206445@lists.php.net to get a copy of this message | ||
[Editor's note: that behavior has changed as of PHP 7.0.0, though.]
Suprisingly consts are lazy bound even though you use self instead of static:
<?php
class A{
const X=1;
const Y=self::X;
}
class B extends A{
const X=1.0;
}
var_dump(B::Y); // float(1.0)
?>
--was--
Suprisingly consts are lazy bound even though you use self instead of static:
<?php
class A{
const X=1;
const Y=self::X;
}
class B extends A{
const X=1.0;
}
var_dump(B::Y); // float(1.0)
?>
http://php.net/manual/en/language.oop5.constants.php