PHP:初始化关联数组时出现意外的T_变量

PHP:初始化关联数组时出现意外的T_变量,php,associative-array,parse-error,Php,Associative Array,Parse Error,我在第92行的path/querys.php中得到了以下错误解析错误:语法错误,意外的T_变量 由于数组$\u queryArray: private $_queryA = ""; etc... private $_queryV = ""; private $_queryArray = array( 'A' => $this->_queryA, //<= line 92 of my code 'B' =&g

我在第92行的path/querys.php中得到了以下错误解析错误:语法错误,意外的T_变量

由于数组
$\u queryArray

private $_queryA = "";
etc...
private $_queryV = "";


private $_queryArray = array(   'A' => $this->_queryA, //<= line 92 of my code
                                'B' => $this->_queryB,
                                'C' => $this->_queryC,
                                'D' => $this->_queryD,
                                'E' => $this->_queryE,
                                'F' => $this->_queryF,
                                'G' => $this->_queryG,
                                'H' => $this->_queryH,
                                'I' => $this->_queryI,
                                'J' => $this->_queryJ,
                                'K' => $this->_queryK,
                                'L' => $this->_queryL,
                                'M' => $this->_queryM,
                                'N' => $this->_queryN,
                                'O' => $this->_queryO,
                                'P' => $this->_queryP,
                                'Q' => $this->_queryQ,
                                'R' => $this->_queryR,
                                'S' => $this->_queryS,
                                'T' => $this->_queryT,
                                'U' => $this->_queryU,
                                'V' => $this->_queryV 
                            );
private$_queryA=”“;
等
私有$_queryV=“”;
private$\u queryArray=array('A'=>$this->\u queryya,//$this->\u queryB,
“C”=>$this->\u queryC,
“D”=>$this->\u queryD,
“E”=>$this->\u queryE,
“F”=>$this->\u查询,
“G”=>$this->\u queryG,
“H”=>$this->\u queryH,
“我”=>$this->\u queryI,
“J”=>$this->\u queryJ,
“K”=>$this->\u queryK,
“L”=>$this->\u queryL,
“M”=>$this->\u queryM,
“N”=>$this->\u queryN,
“O”=>$this->\u queryO,
“P”=>$this->\u queryP,
“Q”=>$this->\u queryQ,
“R”=>$this->\u queryR,
'S'=>$this->\u queryS,
“T”=>$this->\u queryT,
“U”=>$this->\U queryU,
“V”=>$this->\u queryV
);
我填写
$\u queryaray的方式有问题吗?


谢谢大家!

我假设代码来自类声明

我的猜测是,此时您无法访问$this。 尝试在构造函数中设置数组

function __construct() {
    $this->_queryArray = array( ... );
}

由于$this引用实例,并且在定义类时不存在,因此不能在属性定义中使用$this

引述

该声明可能包含一个初始化,但该初始化必须是一个常量值——也就是说,它必须能够在编译时进行计算,并且必须不依赖于运行时信息才能进行计算


很明显,这仍然过于本地化。我可以这样做,但在将查询放入数组之前,我以静态方式填充查询。如果一个构造函数有200行静态填充no:s,那将是非常难看的。那些$\u query\u a类型变量看起来并不是特别静态,也就是说,你不需要200行数组填充,你可以使用一个循环,使它成为一个空数组,然后填充到构造函数中,当你更好地构建查询时,把它变成一个getter函数。