PHP中如何用switch制作页面,php – 如何在Mustache模板中使用switch case?

我在Core PHP中使用Mustache模板将PHP页面转换为模板.现在我想在模板中使用switch case,如:

switch ($gift_card['FlagStatus']) {

case 'P':

echo "Pending";

break;

case 'A':

echo "Active";

break;

case 'I':

echo "Inactive";

break;

}

?&GT

什么应该是类似的胡子翻译?

提前致谢

解决方法:

如果您需要做的不仅仅是从switch语句输出单个值,最简单的解决方法是创建一系列布尔值,每个状态对应一个:isPending,isInactive,isActive等,然后为每个可能性使用单独的部分:

{{#isPending}}

Your gift card is pending. It will be activated on {{activationDate}}.

{{/isPending}}

{{#isActive}}

Your gift card is active. Its balance is ${{balance}}.

{{/isActive}}

{{#isInactive}}

Your gift card is inactive. Go here to reactivate it.

{{/isInactive}}

标签:php,switch-statement,mustache

来源: https://codeday.me/bug/20190729/1571584.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值