[英]Parse error: syntax error, unexpected '[', expecting ')' php
I am creating a custom shipping method for opencart, however i am stuck on the catalog model file, which is for PHP 5.4+
, but how do i make it working with PHP 5.3
as Opencart Requirement is start from PHP 5.3我正在为 opencart 创建自定义运输方法,但是我被困在目录模型文件上,该文件适用于
PHP 5.4+
,但是我如何使它与PHP 5.3
一起使用,因为 Opencart 要求是从 PHP 5.3 开始的
catalog/model/shipping/items.php
目录/模型/运输/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')))
);
this line working fine with PHP 5.4+ but not PHP 5.3这条线在 PHP 5.4+ 上工作正常,但在 PHP 5.3 上不工作
'title'=> $this->config->get('items_shipping_description')[$languages],
I get an error for PHP 5.3 which is我收到 PHP 5.3 的错误消息
Parse error: syntax error, unexpected '[', expecting ')' in ...
I've also read many duplicate question and tried many different way to make this working with no luck!我还阅读了许多重复的问题,并尝试了许多不同的方法来使这个工作没有运气! please help, thank you!
请帮忙,谢谢!
Just assign it to variable: $description = $this->config->get('items_shipping_description')
And then use:只需将其分配给变量:
$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')))
);
$this->config->get('items_shipping_description')[$languages]
This is function array dereferencing and was only added in php 5.4这是函数数组解引用,仅在php 5.4 中添加
To make it work with php 5.3 you will need to assign that return value to a variable and then use that.要使其与 php 5.3 一起使用,您需要将该返回值分配给一个变量,然后使用它。
$items = $this->config->get('items_shipping_description');
$items[$languages];
Try this,尝试这个,
$desc = $this->config->get('items_shipping_description');
And和
'title' => $desc[$languages],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.