Try this:
$test = array (2+2);
var_dump($test);
Then try the same but inside a class:
class test {
public $test = array(2+2);
}
I just want to know why one gets a parser error and maybe how to solve this (in a class) as code-friendly and performant as possible.
You cannot use statements to initialize class fields. It must be a literal, a constant value. A workaround is to use a constructor:
From the manual: