【问题标题】:display('string:'.$template_string) do not workdisplay('string:'.$template_string) 不起作用
【发布时间】:2018-04-29 18:41:41
【问题描述】:

我尝试使用

$template = "<h1>Hello {name},</h1>";
$smarty->assign('name','Christian');
$output = $smarty->fetch('string:' . $template);
echo $output;

结果是:

Hello ,

它输出模板,但不显示模板中的变量。我用的是最新的Smarty 3.1.32 什么问题 谢谢Christian的帮助

【问题讨论】:

标签: php html templates smarty smarty3


【解决方案1】:

您可以像在 php 中一样使用 smarty 中的变量。所以应该是:$template = "&lt;h1&gt;Hello {$name},&lt;/h1&gt;";

【讨论】:

    猜你喜欢
    • 2023-03-29
    • 2015-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-08
    • 2018-03-01
    • 2016-09-22
    • 1970-01-01
    相关资源
    最近更新 更多