PHP expression for class constant

constants, php, string

Solution

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.

Problem

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.

Original source

Related problems