我在CakePHP中开发了一个应用程序--Windows。
然后我把它放在Ubuntu中并做了必要的设置。一切都有效,除了这一行:
$this-> set (
'projeto_id',
$this-> requestAction (
"/Projects/getprojectsofcategory",
array (
'setor_id' => $this->Registration-> read()['Registration']['setor_id']
)
)
);
给了我以下错误:
致命错误错误:语法错误,意外'[',期待')'
我不明白为什么。如果我注释掉该行会出现以下错误,因为它属于同一类型。
有人可以解释一下这个错误的原因吗?
答案 0 :(得分:5)
您需要升级到较新版本的PHP,否则您将需要更改功能。
查看this post投票最多的答案。 $this->Registration->read()['Registration']
不适用于PHP< 5.4
如果你无法升级php,你需要有一个中介变量
$valueRead = this->Registration->read();
$this-> set (
'projeto_id',
$this-> requestAction (
"/Projects/getprojectsofcategory",
array (
'setor_id' => $valueRed['Registration']['setor_id']
)
)
);