I'm trying to do something like a bitwise enum in PHP according to this answer. However, while it worked nicely when I had defined all constants as regular ints like this:
final class CountryEnum {
const CZ = 1; //Czech Republic
const DE = 2; //Germany
const DK = 4; //Denmark
//12 more
const US = 32768; //USA
}
It doesn't work when I try to define the values via a bit-shift pattern, i.e.:
final class CountryEnum {
const CZ = 1; //Czech Republic
const DE = 1 << 1; //Germany
const DK = 1 << 2; //Denmark
//12 more
const US = 1 << 15; //USA
}
When I try to run this, PHP thows a fit saying
Parse error: parse error, expecting
','' or
';'' in CountryEnum.php on line [the line with const DE]
So I am probably missing some fundamental basic thingy, but I'm at a loss.