Strange parse error with static concatenated string variable

I get this error:

Parse error: syntax error, unexpected '.', Pending ',' or ';' in / var / (...) / config.php on line 5

With this (simplified) code:

<?php

class Config
{
   public static $somevar = "Date: " . date('Y');
}

?>

I thought this was valid php, but I don’t think ... what am I doing wrong here? Thank!

+5
source share
3 answers

In accordance with the documents :

PHP, ; . , (), , .

Config::$somevar = "Date: " . date('Y');

.

+5

, .

+2

Manual

PHP, ; . , (), , .

+1

All Articles