Reply to Class constants

Your name:

Reply:


Posted by Marcus Bointon on 10/21/65 11:22

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация