Can anyone tell me why this doesn’t work?
It’s just a crude example of what I’m trying to do somewhere else.
$stuff = array(
'key' => __DIR__ . 'value'
);
However, this produces an error:
PHP Parse error: syntax error, unexpected '.', expecting ')' in /var/www/.../testing.php on line 6
Also, this works:
$stuff = array(
'key' => "{__DIR__} value"
);
The first piece of code does not work because it’s not a constant expression, as you are trying to concatenate two strings. Initial class members must be constant.
From the documentation: