<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.syntax.quotes.html" accesskey="P">Prev</a></td> <td width="50%" align="center" valign="bottom">Chapter 3. Basic Syntax[第3章.基本语法]</td> <td width="25%" align="right" valign="bottom"><a href="language.syntax.escape_parsing.html" accesskey="N">Next</a></td></tr></table> # Math[数学运算] Math can be applied directly to variable values. 数学运算可以直接作用到变量值。 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="EXAMPLE"><tr><td><div class="EXAMPLE"><a name="AEN237" id="AEN237"/> <b>Example 3-7. math examples<br/></b><strong>例 3-7.数学运算的例子 </strong> <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="PROGRAMLISTING">{$foo+1}{$foo*$bar}{* some more complicated examples *} {* 一些更复杂的示例 *}{$foo-&gt;bar-$bar[1]*$baz-&gt;foo-&gt;bar()-3*7}{if ($foo+$bar.test%$baz*134232+10+$b+10)}{$foo|truncate:"`$fooTruncCount/$barTruncFactor-1`"}{assign var="foo" value="`$foo+$bar`"}</pre></td></tr></table><table width="80%" border="0" cellpadding="2" cellspacing="2" class="note"><caption> 提示 </caption> <tr><td>Note<br/> Although Smarty can handle some very complex expressions and syntax, it is a good rule of thumb to keep the template syntax minimal and focused on presentation. If you find your template syntax getting too complex, it may be a good idea to move the bits that do not deal explicitly with presentation to PHP by way of plugins or modifiers.<br/> 虽然Smarty能处理一些复杂的表达式和语法,但从经验上来说的,一个好的做法是最低限度使用模板语法,将其专注于表现外在内容。如果发现你的模板语法太复杂,最好将与外在表现无关的后台处理通过插件或调节器交给php处理。</td> </tr></table></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.syntax.quotes.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.syntax.escape_parsing.html" accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Embedding Vars in Double Quotes<br/> 双引号里值的嵌入 </td><td width="34%" align="center" valign="top"><a href="language.basic.syntax.html" accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Escaping Smarty Parsing<br/> 忽略Smarty解析</td></tr></table>