Get Smarty

Donate

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Buy cheap glasses from Cheapglasses123.com and save up to 80%.

Where to buy prescription glasses? EyewearCanada.com is your best choice!

Visit www.sport-kick.com for cheap soccer cleats, sneakers and Soccer Jerseys updates

Advertisement

{append}

{append}可以在 运行时 为数组变量增加或者创建值。

Note

这需要考虑的是,对于模板中变量的赋值,最好尽量是放到PHP程序代码中进行。

属性:

参数名称 类型 必选参数 默认值 说明
var string Yes n/a 赋值的变量名称
value string Yes n/a 赋予的值
index string No n/a 数组元素的新索引,如果没有提供此参数,则附加的值会加到数组最后。
scope string No n/a 赋值变量的访问范围: 'parent','root' 或 'global'

可选的标记:

名称 说明
nocache 为变量增加'nocache'属性

Example 7.7. {append}


{append var='name' value='Bob' index='first'}
{append var='name' value='Meyer' index='last'}
// or 
{append 'name' 'Bob' index='first'} {* short-hand *}
{append 'name' 'Meyer' index='last'} {* short-hand *}

The first name is {$name.first}.<br>
The last name is {$name.last}.

  

输出:


The first name is Bob.
The last name is Meyer.

  

参见append()getTemplateVars().

Comments
No comments for this page.

Advertisement