1. 程式人生 > >PHP之smarty程式碼之if else if程式碼的使用

PHP之smarty程式碼之if else if程式碼的使用

if,elseif,else

Smarty 中的 if 語句和 php 中的 if 語句一樣靈活易用,並增加了幾個特性以適宜模板引擎. if 必須於 /if 成對出現. 可以使用 else 和 elseif 子句.

$smarty->assign("sex","2");//賦值

1.if else

<div>
    {if $sex=="1"}男
       {else}女
    {/if}
 </div>

2.if  elseif  if

3.if elseif else if