Parse error: syntax error, unexpected '[', expecting ')' php
Parse error: syntax error, unexpected '[', expecting ')' php
我正在为 opencart 创建自定义运输方式,但是我卡在目录模型文件上,该文件适用于 PHP 5.4+
,但我如何使其与 PHP 5.3
一起作为 Opencart 要求从 PHP 5.3
开始
catalog/model/shipping/items.php
$languages = $this->language->get('code');
$quote_data = array();
$quote_data['items'] = array(
'code' => 'items.items',
'title' => $this->config->get('items_shipping_description')[$languages],
'cost' => $this->config->get('items_cost'),
'tax_class_id' => $this->config->get('items_tax_class_id'),
'text' => $this->currency->format($this->tax->calculate($items_cost, $this->config->get('items_tax_class_id'), $this->config->get('config_tax')))
);
此行适用于 PHP 5.4+ 但不适用于 PHP 5.3
'title'=> $this->config->get('items_shipping_description')[$languages],
我收到 PHP 5.3 的错误,即
Parse error: syntax error, unexpected '[', expecting ')' in ...
我也读过很多重复的问题并尝试了很多不同的方法来使这个工作没有运气!请帮忙,谢谢!
只需将其分配给变量:
$description = $this->config->get('items_shipping_description')
然后使用:
$quote_data['items'] = array(
'code' => 'items.items',
'title' => $description[$languages]
'cost' => $this->config->get('items_cost'),
'tax_class_id' => $this->config->get('items_tax_class_id'),
'text' => $this->currency->format($this->tax->calculate($items_cost, $this->config->get('items_tax_class_id'), $this->config->get('config_tax')))
);
试试这个,
$desc = $this->config->get('items_shipping_description');
和
'title' => $desc[$languages],
$this->config->get('items_shipping_description')[$languages]
这是函数数组取消引用,仅在 php 5.4
中添加
要使其与 php 5.3 一起使用,您需要将 return 值分配给一个变量,然后使用它。
$items = $this->config->get('items_shipping_description');
$items[$languages];
我正在为 opencart 创建自定义运输方式,但是我卡在目录模型文件上,该文件适用于 PHP 5.4+
,但我如何使其与 PHP 5.3
一起作为 Opencart 要求从 PHP 5.3
catalog/model/shipping/items.php
$languages = $this->language->get('code');
$quote_data = array();
$quote_data['items'] = array(
'code' => 'items.items',
'title' => $this->config->get('items_shipping_description')[$languages],
'cost' => $this->config->get('items_cost'),
'tax_class_id' => $this->config->get('items_tax_class_id'),
'text' => $this->currency->format($this->tax->calculate($items_cost, $this->config->get('items_tax_class_id'), $this->config->get('config_tax')))
);
此行适用于 PHP 5.4+ 但不适用于 PHP 5.3
'title'=> $this->config->get('items_shipping_description')[$languages],
我收到 PHP 5.3 的错误,即
Parse error: syntax error, unexpected '[', expecting ')' in ...
我也读过很多重复的问题并尝试了很多不同的方法来使这个工作没有运气!请帮忙,谢谢!
只需将其分配给变量:
$description = $this->config->get('items_shipping_description')
然后使用:
$quote_data['items'] = array(
'code' => 'items.items',
'title' => $description[$languages]
'cost' => $this->config->get('items_cost'),
'tax_class_id' => $this->config->get('items_tax_class_id'),
'text' => $this->currency->format($this->tax->calculate($items_cost, $this->config->get('items_tax_class_id'), $this->config->get('config_tax')))
);
试试这个,
$desc = $this->config->get('items_shipping_description');
和
'title' => $desc[$languages],
$this->config->get('items_shipping_description')[$languages]
这是函数数组取消引用,仅在 php 5.4
中添加要使其与 php 5.3 一起使用,您需要将 return 值分配给一个变量,然后使用它。
$items = $this->config->get('items_shipping_description');
$items[$languages];