PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I dont seem to be able to declare a class array constant. I want to be able to do myclass::propertyTypes. What is the right syntax? or is it not possible?
Not sure about class constants but I know for normal constants only scalar and null values are allowed. Scalar values being integer, float, string or boolean values. Maybe that has an effect. You could always just set it as a private variable if you are just using it within the class.
yacahuma wrote:Why limit what a constant could be? If i now the array will never change. I am wondering what is the rationale behind it.
Thank you
An array is not scalar. Scalar values need no further processing or evaluation to be formulated. For all intents and purposes they are constant. Arrays require evaluation, therefore not scalar.