Php 显示$params数组(';{item}';=>;…;)

Php 显示$params数组(';{item}';=>;…;),php,arrays,oop,smarty,prestashop-1.6,Php,Arrays,Oop,Smarty,Prestashop 1.6,我需要一些帮助。在Prestashop中的PaymentModule.php中包含此代码: $params = array( '{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false), '{voucher_num}' => $voucher->code, '{firstname}' =>

我需要一些帮助。在Prestashop中的
PaymentModule.php
中包含此代码:

$params = array(
    '{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
    '{voucher_num}' => $voucher->code,
    '{firstname}' => $this->context->customer->firstname,
    '{lastname}' => $this->context->customer->lastname,
    '{id_order}' => $order->reference,
    '{order_name}' => $order->getUniqReference()
);
我使用
$params['firstname']
来显示客户
firstname
,但什么也得不到。我在
/modules/bankwire/bankwire.php

请告诉我哪里出错了

谢谢

试试看

$params = array(
    'voucher_amount' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
    'voucher_num' => $voucher->code,
    'firstname' => $this->context->customer->firstname,
    'lastname' => $this->context->customer->lastname,
    'id_order' => $order->reference,
    'order_name' => $order->getUniqReference()
);
或者如果沃克是对的,试试看

$params['{firstname}'] 

在数组中有一个
{firstname}
键,但没有
firstname


如果您想获取值,应该使用:
$params['{firstname}']

电子邮件模板有变量,它只是一个assoc数组,供访问使用

$params['{voucher_amount}']

从数组键中删除
{}
,即
$params=array('firstname'=>…,)
。肯尼:你为什么确定这些键是错的?该问题带有
smarty
prestashop-1.6
标记,因此它很可能是一个模板,删除大括号可能会破坏它。感谢编辑我的问题。很抱歉,我是新来的,不太懂格式。您在哪里定义$params数组?您想在哪里使用该条目?要么该值为真空,因为没有输入名字,要么涉及某种转换,例如是否存在将$param元素绑定到视图模板的机制?为什么确定键是错误的?问题被标记为
smarty
prestashop-1.6
,因此它很可能是一个模板,删除大括号可能会破坏它。谢谢,但我尝试了这种方法-$params[{firstname}],什么都没有。简单字符串显示良好,但不显示数组项。您能告诉我其他的解决方案吗?请尝试:
print\r($params)
并告诉我们您得到了什么输出