PHP解析错误:语法错误,意外' ['

时间:2016-02-01 01:31:43

标签: php joomla

我有几行产生错误500.错误日志说:

  

PHP Parse错误:语法错误,意外' ['在...

并且行是:

 $catids[] = $params->get('catid');

在评论之后,出现了这个:

$return_category[] = self::_getCategoryInfor($tg, $params)[0];

如何修改它们以匹配新的PHP版本并解决错误500?

2 个答案:

答案 0 :(得分:0)

从您的代码中,我看不到可能触发此解析错误的代码。尝试更改您的代码,使其变为:

$categories = self::_getCategoryInfor($tg, $params);
$return_category[] = $categories[0];

答案 1 :(得分:0)

这是导致错误的表达式:

function getTimeRemaining(starttime, endtime){
  // translate JSdate to Ms before you can compare
  var nowInMs = new Date().getTime();
  var startTimeMs = starttime.getTime();
  
  if (nowInMs < startTimeMs) {
    ... do what you wanted, maybe compare diff and count from there
    ... or just not show the timer
  } else {
    ... do what you were doing
  }

在PHP 5.4中添加了函数数组解除引用。您的代码将在5.3或更低版本生成解析错误:

https://secure.php.net/manual/en/migration54.new-features.php