I'm trying to insert a static variable in an array like this :
static $datas = array(
'link' => config::$link
);
But i'm having this error
Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING
I discovered PHP doc say that :
Like any other PHP static variable, static properties may only be initialized using a literal or constant; expressions are not allowed. So while you may initialize a static property to an integer or array (for instance), you may not initialize it to another variable, to a function return value, or to an object.
But I'm sure there is a way to do that, any suggestion ?
$datasa static variable here? Otherwise this question makes little sense. Please provide a complete working code snippet that reproduces this error.static $var = null; if (is_null($var)) $var = array( /* actual dynamic initialization */ ), which you might think could be safely implemented in PHP itself, but it isn't just because.