我的代码:如何在数组中声明一个静态数组?
class User
{
protected static $config = array(
'expiration' => 0,
);
protected static $Db;
protected static $user = array();
static::$user['data'] = array();
static::$user['meta'] = array();
static::$user['controls'] = array();
在这里,我会得到这个错误:
Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM), expecting variable (T_VARIABLE)
抱怨这一点:
`static::$user['data'] = array()`
我如何声明静态:: $用户[ '数据' ] 这里?
你不能声明数组内的静态变量。初始数组将是静态的,因此您无需将其关键值静态化。 –
在类方法中的某处:'self :: $ user ['key'] = array()' –