3

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.

Joey
  • 344,408
  • 85
  • 689
  • 683
Marcus Johansson
  • 2,626
  • 2
  • 24
  • 44

1 Answers1

5

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.

KingCrunch
  • 128,817
  • 21
  • 151
  • 173
Joey
  • 344,408
  • 85
  • 689
  • 683