I'm trying to declare a public static variable that is a array of arrays:
class Foo{
public static $contexts = array(
'a' => array(
'aa' => something('aa'),
'bb' => something('bb'),
),
'b' => array(
'aa' => something('aa'),
'bb' => something('bb'),
),
);
// methods here
}
function something($s){
return ...
}
But I get a error:
Parse error: parse error, expecting `')'' in ...
You can't use expressions when declaring class properties. I.e. you can't call
something()
here, you can only use static values. You'll have to set those values differently in code at some point.For example:
Or do it in
__construct
if you're going to instantiate the class.