Smarty模板添加到变量错误

时间:2011-11-22 20:31:38

标签: php smarty

我想

    {$mouseOver = "test"}
    {$mouseOver .= " continue"}

就像我可以在简单的php中做到这一点:

$test = "Hello";
$test .= " continue";

echo $test; // will output: Hello continue

在Smarty PHP模板中。我该怎么办呢?

2 个答案:

答案 0 :(得分:1)

v2p在正确的轨道上,但具体你会这样做:

{assign var="varname" value="Hello"}
{assign var="varname" value="{$varname} World"}

{$varname}

这将打印“Hello World”,$varname将继续保持该值,直到进一步修改。

答案 1 :(得分:0)

尝试{assign var='name' value='some value'}

请参阅http://www.smarty.net/docsv2/en/language.custom.functions.tpl#language.function.assign


如何使用字符串连接,使用cat修饰符

请参阅http://www.smarty.net/docsv2/en/language.modifier.cat

相关问题