功能:条件判断(分支)
基本语法:
{if}
{elseif}
{else}
{/if}
demo4.html示例代码:
<!DOCTYPE html> <html> <head> <meta charset=’utf-8′> <title></title> </head> <body> {if $i==1} 吃饭 {elseif $i==2} 读书 {elseif $i==3} 敲代码 {else} 睡觉 {/if} </body> </html>
demo4.php
<?php require “smarty/Smarty.class.php”; $smarty = new Smarty(); $i = ‘2’; $smarty -> assign(‘i’,$i); $smarty -> display(“demo4.html”);
时间: 2024-10-30 11:51:53