夺命雷公狗---Smarty NO:08 if–elseif–else函数

功能:条件判断(分支)

基本语法:

{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”);

 

posted @ 2015-12-09 15:56  夺命雷公狗  阅读(151)  评论(0编辑  收藏  举报