ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
<table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><th colspan="3" align="center">Smarty - the compiling PHP template engine</th></tr><tr><td width="25%" align="left" valign="bottom"><a href="language.function.var.html" accesskey="P">Prev</a></td> <td width="50%" align="center" valign="bottom">Chapter 7. Built-in Functions[第七章.内置函数]</td> <td width="25%" align="right" valign="bottom"><a href="language.function.assign.html" accesskey="N">Next</a></td></tr></table> # {append} 追加 {append} is used for creating or appending template variable arrays during the execution of a template. {append}用于在模板执行期间建立或追加模板变量数组。 <table width="80%" border="0" cellpadding="2" cellspacing="2" class="note"><caption> 提示 </caption> <tr><td>Note<br/> Assignment of variables in-template is essentially placing application logic into the presentation that may be better handled in PHP. Use at your own discretion.<br/> 在模板里为变量赋值本质上来说是为外观描述放置应用程序,一般来说变量赋值行为在php代码中操作比较好。不过,一切由你定夺。</td> </tr></table> **Attribute: ** | Attribute Name | Type | Required | Default | Description | |-----|-----|-----|-----|-----| | name | string | yes | *n/a* | The name of the variable being assigned | | value | string | yes | *n/a* | The value being assigned | | index | string | no | *n/a* | The index for the new array element.If not specified the value is append to the end of the array. | | scope | string | no | *n/a* | The scope of the assigned variable:'parent','root' or 'global' | **option flags:** | **Name** | **Description** | |-----|-----| | nocache | Assingns the variable with the 'nocache' attribute | **属性: ** | 属性名 | 类型 | 是否必须 | 缺省值 | 描述 | |-----|-----|-----|-----|-----| | name | string | yes | *n/a* | 要赋值的变量名 | | value | string | yes | *n/a* | 赋值 | | index | string | no | *n/a* | 新数组元素的下标,如果没有指定的该值,(数组元素将)添加到数组的末尾。 | | scope | string | no | *n/a* | 分配的变量范围:'parent','root' or 'global' | **选项标签:** | **名称** | **描述** | |-----|-----| | nocache | 用'nocache' 属性为变量赋值 | <table width="100%" border="0" cellpadding="0" cellspacing="0" class="EXAMPLE"><tr><td><div class="EXAMPLE"> <a name="AEN794"> </a> <b>Example 7.7. {append}<br/> 例 7-7.{append}</b> <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="PROGRAMLISTING">{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}.&lt;br&gt;The last name is {$name.last}. The above example will output:The first name is Bob.The last name is Meyer. </pre> </td> </tr></table><p><span class="PROGRAMLISTING">See also append() and getTemplateVars(). <br/> 参考<a href="api.append.html">append()</a>和<a href="api.get.template.vars.html">getTemplateVars()</a>。</span></p> </div></td> </tr></table> <table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="language.function.var.html" accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="language.function.assign.html" accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">{$var=}<br/> 变量赋值<br/></td><td width="34%" align="center" valign="top"><a href="language.builtin.functions.html" accesskey="U">Up</a></td><td width="33%" align="right" valign="top">{assign}<br/> 赋值</td></tr></table>