Class constants

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx | http://www.synchromedia.co.uk

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux