企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
<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.syntax.attributes.html">Prev</a></td><td width="50%" align="center" valign="bottom"/><td width="25%" align="right" valign="bottom"><a href="language.variables.assigned.html">Next</a></td></tr></table> # [Chapter 4. Variables[第四章.变量]]() **第四章.变量** **Table of Contents[内容列表]**[Variables assigned from PHP](#)[从PHP分配的变量][Variable scopes](#) [变量范围] [Variables loaded from config files](#)[从配置文件读取的变量][{$smarty} reserved variable](#)[{$smarty} 保留变量 Smarty has several different types of variables. The type of the variable depends on what symbol it is prefixed with (or enclosed within). Variables in Smarty can be either displayed directly or used as arguments for function attributes and modifiers, inside conditional expressions, etc. To print a variable, simply enclose it in the delimiters so that it is the only thing contained between them. Examples: Smarty有几种不同类型的变量,变量的类型取决于它的前缀符号是什么(或者被什么符号包围)。 Smarty的变量可以直接被输出或者作为函数属性和调节器(modifiers)的参数,或者用于内部的条件表达式等等。如果要输出一个变量,只要用定界符将它括起来就可以。例如: **Example 4.1. Example variables** **例 4-1.分配的变量** | ~~~ {$Name}{$product.part_no} <b>{$product.description}</b>{$Contacts[row].Phone}<body bgcolor="{#bgcolor#}"> ~~~ | |-----| <table width="80%" border="0" cellpadding="2" cellspacing="2" class="note"><caption> 提示 </caption> <tr><td><p>Note<br/> An easy way to examine assigned Smarty variables is with the debugging console.<br/> 一个检验是否为Smarty变量的简单方法就是执行<a href="chapter.debugging.console.html">调试控制器</a>(debugging console,Smarty类中有专门一种方法$smarty-&gt;debugging = true;) </p> </td> </tr></table> <table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="language.syntax.attributes.html">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html">Home</a></td><td width="33%" align="right" valign="top"><a href="language.variables.assigned.html">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Attributes<br/> 属性</td> <td width="34%" align="center" valign="top"><a href="smarty.for.designers.html">Up</a></td> <td width="33%" align="right" valign="top" class="SECT1">Variables assigned from PHP<br/> 从PHP分配的变量</td> </tr></table>