Class constants
| From: | Marcus Bointon | Date: | Thu, 28 Jul 2005 10:49:25 +0000 |
| Subject: | Class constants | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-219476@lists.php.net to get a copy of this message | ||
I'm not sure if this is a bug or a feature, but it seems 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. Comments? Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture marcus@synchromedia.co.uk | http://www.synchromedia.co.uk