【问题标题】:Parse error: syntax error, unexpected '[' line 149解析错误:语法错误,意外的“[”第 149 行
【发布时间】:2014-09-10 19:31:59
【问题描述】:

我有这个错误。这是我的代码。你能帮我吗? ??? ? ?第 149 行是最后一行 :(

    $customer_group_info = $this->model_sale_customer_group->getCustomerGroup($order_info['customer_group_id']);

    if ($customer_group_info) {
        $this->data['customer_group'] = $customer_group_info['name'];
    } else {
        $this->data['customer_group'] = '';
    }

    $this->load->model('localisation/order_status');
    $this->data['order_status'] = $this->model_localisation_order_status->getOrderStatus($order_info['order_status_id'])['name'];

【问题讨论】:

  • 这是什么语言? php?
  • 您不能在返回值上使用订阅[] 运算符(例如来自getOrderStatus)。您需要先将其存储在变量中。

标签: php parsing line


【解决方案1】:

你不能使用返回数组的函数并直接使用它的结果。 您必须将结果绑定到一个变量,然后使用它。

$temp = $this->model_localisation_order_status->getOrderStatus($order_info['order_status_id']);
$this->data['order_status'] = $temp['name'];

编辑:Access an Array Returned by a Function 的副本

【讨论】:

    猜你喜欢
    • 2011-06-24
    • 2013-12-09
    • 1970-01-01
    • 2014-05-24
    • 2013-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多