Get Smarty

Donate

Paypal

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

Advertisement

{while}

Smarty における {while} ループは、PHP の while と同等の柔軟性を持っています。 さらに、テンプレートエンジンのための機能をいくつか追加しています。 全ての {while} は、対応する {/while} とペアである必要があります。 ||or&&andis_array() など、PHP の条件演算子や関数はすべて利用可能です。

以下は認識される条件演算子の一覧です。 これらはスペースによって周りの要素から分離される必要があります。 [ ] で囲まれた要素は任意であることに注意しましょう。 "PHP 相当" には、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 割り切れる $a % $b == 0
is [not] even   $a is not even 偶数である [ない] (単項) $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.75. {while} ループ



{while $foo > 0}
  {$foo--}
{/while}

  

上の例は、$foo の値を 1 になるまでカウントダウンします。


{foreach}{for} および {section} も参照ください。

Comments
No comments for this page.

Advertisement

Sponsors [info]

Sponsors