Consider the following:
$var = 'foo' . 'bar'; # Not a member of a class, free-standing or in a function.
As soon as I mark $var as static, however:
static $var = 'foo' . 'bar';
PHP (5.3.1 on a WAMP setup) complains with the following error:
Parse error: syntax error, unexpected ‘.’, expecting ‘,’ or ‘;’
It seems that the string concatenation is the culprit here.
What’s going on here? Can someone explain the rules for static variables to me?
The manual states, in Variables scope:
There is also mention of it in Static keyword:
Although it should be noted that a property, static or not, cannot be initialized using an expression neither.