I'm getting an error on line 5 of the code below when trying to concat two strings. I know I can simply combine the strings "a default value\n"
, but I would like to know why the following doesn't work as is.
<?php
class SimpleClass
{
// property declaration
public $var = 'a default value' . "\n"; //ERROR ON THIS LINE
// method declaration
public function displayVar() {
echo $this->var;
}
}
$a = new SimpleClass();
echo $a->var;
$a->displayVar();
?>