note 55187 rejected from language.oop5.constants by betz
| From: | betz@php.net | Date: | Thu, 28 Jul 2005 09:44:14 +0000 |
| Subject: | note 55187 rejected from language.oop5.constants by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-92617@lists.php.net to get a copy of this message | ||
Note Submitter: marcus at synchromedia dot co dot uk
----
I'm not sure if this is a bug or a feature, but you can't use class constants to set
default values for class properties. You can, however, use them for default values for method
params, e.g.:
class foo {}
const BAR = 100;
private $thing = self::BAR;
function wibble($a = self::BAR) {
echo $a;
}
}
In this case $this->thing will be undefined, but wibble() will get the correct default value for
$a.