Why is it wrong to define the value of a class attribute like this? I think it is because I cannot allocate memory space to the attribute. I hope you can explain it a lot?
Why is it wrong to define the value of a class attribute like this?
I think it is because I cannot allocate memory space to the attribute,I hope you will give me some explanations?
Reply content:
Why is it wrong to define the value of a class attribute like this?
I think it is because I cannot allocate memory space to the attribute,I hope you will give me some explanations?
Take a look at the document.
The variables in the property can be initialized, but the initialization value must be a constant. the constant here means that the PHP script can obtain the value during the compilation phase, the value can be evaluated without running information.
Http://php.net/manual/zh/language.oop5.properties.php