> Hi, > > This is not allowed since declaration values should be resolvable at > compile time. I.e. they can not be an expression, but only a value > literal. > > While technically expression folding is possible, it's not implemented in > any part of the PHP engine (AFAIK), and I don't think it's planned any > time soon. > > To do what you want, initialize the value in the constructor: > > class foo { > ... > private $flags; > > function __construct() > { > $this->flags = self::FLAG_1 | self::FLAG_3; > } > } >
Hi, ok, and could you please point out to the thing in self::FLAG_1 that is unresolveable at compile-time? To me it seems that nothing prevents from declaring constants based on the other constants. Since self is always resolveable, such declarantions can be allowed. > $this->flags = self::FLAG_1 | self::FLAG_3; this is not the best solution because it executes the statements each time you create an instance of foo class, while the class constant would be calculated only once at compile-time. just my 2c. jv -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php