多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
<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.section.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.custom.functions.html" accesskey="N">Next</a></td></tr></table> # {while}循环 {while} loopss in Smarty have much the same flexibility as PHP while [http://php.net/while] statements,with a few added features for the template engine. Every {while} must be paired with a matching {/while}. All PHP conditionals and functions are recognized, such as ||, or, &&, and, is_array(), etc. The following is a list of recognized qualifiers, which must be separated from surrounding elements by spaces. Note that items listed in [brackets] are optional. PHP equivalents are shown where applicable. 随着一些特性加入到模版引擎,Smarty的{while}循环与php的while语句一样富有弹性。每一个{while}必须与一个{/while}成对出现,所有php条件和函数在它身上同样适用,诸如||、or、&&、and、is_array()等等。 下面是一串有效的限定符,它们的左右必须用空格分隔开,注意列出的清单中方括号是可选的,在适用情况下使用相应的等号(全等或不全等)。 ![while](https://box.kancloud.cn/2015-09-02_55e669a11f33d.gif) <table width="100%" border="0" cellpadding="0" cellspacing="0" class="EXAMPLE"><tr><td><div class="EXAMPLE"> <p><a name="AEN2775" id="AEN2775"/><b><span class="PROGRAMLISTING">Example 7.75. {while} loop</span><br/> 例 7-75. {while}循环 </b></p> <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="PROGRAMLISTING">{while $foo &gt; 0} {$foo--}{/while}</pre></td></tr></table><p>The above example will count down the value of $foo until 1 is reached.<br/> See also {foreach} and {for}.</p> <p>上面的例子会倒计数$foo的值,直至$foo等于1。参见<a href="language.function.foreach.html">{foreach}</a>和<a href="language.function.for.html">{for}</a>。</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.section.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.custom.functions.html" accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">{section},{sectionelse}<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">include_php</td></tr></table>