Reputation: 2667
I'm trying to figure out why I get and exception with this code.
class Test {
const test = "Two " .
"rows.";
}
I get an exception on the row containing the const:
Parse error: syntax error, unexpected '.', expecting ',' or ';' in /home/BZUMUL/prog.php on line X
I was going to switch to heredoc but then I got too curious so I couldn't stop trying to solve it.
Upvotes: 3
Views: 1970
Reputation: 354704
According to Class Constants:
The value must be a constant expression, not (for example) a variable, a property, a result of a mathematical operation, or a function call.
So you cannot use an expression for the constant value.
Upvotes: 5