I found this new feature a lot of way around PHP 5.6.
It is now possible to set a array
to the value of a constant.
See how cool:
const BR_DATES = [
1 => 'Janeiro',
2 => 'Fevereiro',
3 => 'Março',
4 => 'Abril'
];
print_r(BR_DATES); // Array ( [1] => Janeiro [2] => Fevereiro [3] => Março [4] => Abril )
echo BR_DATES[date('n')]; // Março
I see that this implementation reduces pollution in the global scope in relation to the definition of numerous constants. In addition, it becomes very useful in reusing values that could be used in a fixed way, as in the case above.
In addition to the outstanding benefits, what are the other benefits that this new implementation will bring?
Would this implementation of the constant accept an array be the same as the Python Tuple ?
Does this implementation have any bad effects over previous versions?