If I use a “dot” to assign a value in a variable in a PHP class, it fails.
For example:
class bla {
public $a = 'a' . 'b';
}
How should I approach this otherwise?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can only do that in the constructor, as class variables/properties must be initialized on declaration with constant expressions. From the manual:
This means you can’t use any operators or function calls.