Get Smarty


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 and save up to 80%.

Where to buy prescription glasses? is your best choice!

Where to buy discount wedding dresses and cheap smart dresses free shipping -

Shop for 2018 World Cup Football Boots Online sale at

Browse best 2018 world cup soccer cleats and shoes from



Smarty的{while}循环和PHP的while 在灵活性方面是几乎一样的,只是增加了少许特性。 每个{while}必须有相应的{/while}. 任何的PHP条件或者函数表达式都是可用的,如||, or, &&, and, is_array(), 等等.

下面是可用的运算符列表,使用中都会放到元素的中间并且用空格分隔。 注意列表中[方括号]的是可选的,而且还会列出对应PHP的表达式。

运算符 别名 语法示例 含义 对应PHP语法
== eq $a eq $b 等于 ==
!= ne, neq $a neq $b 不等于 !=
> gt $a gt $b 大于 >
< lt $a lt $b 小于 <
>= gte, ge $a ge $b 大于等于 >=
<= lte, le $a le $b 小于等于 <=
===   $a === 0 绝对等于 ===
! not not $a 非 (一元运算) !
% mod $a mod $b 取模 %
is [not] div by   $a is not div by 4 取模为0 $a % $b == 0
is [not] even   $a is not even [非] 取模为0 (一元运算) $a % 2 == 0
is [not] even by   $a is not even by $b 水平分组 [非] 平均 ($a / $b) % 2 == 0
is [not] odd   $a is not odd [非] 奇数 (一元运算) $a % 2 != 0
is [not] odd by   $a is not odd by $b [非] 奇数分组 ($a / $b) % 2 != 0

Example 7.79. {while} 循环

{while $foo > 0}



参见 {foreach}, {for}{section}.

No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Email: (not shown)
What is 8 plus 13? (Are you human?)