Example of usage of smart template conditional judgment in php
Template file test6.html code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
Smarty Test
{if $cond == 1}
条件成立 |
{else}
条件不成立 |
{/if}
|
1
2
3
4
5
1
2
3
4
5
6
7
|
require 'libs/Smarty.class.php'; //包含Smarty类库文件
$smarty = new Smarty; //创建一个新的Smarty对象
$cond = 1;
$smarty->assign("cond",$cond); //对模版中的变量赋值
$smarty->display('test6.htm'); //显示页面
?>
|
6
7
8
9
10
11
12
13
14
15
16
18
|
Smarty Test
{if $cond == 1}
Condition established |
{else}
The condition is not met |
{/if}
|
php code:
1
2
3
4
5
6
7
|
<🎜>require 'libs/Smarty.class.php'; //Contains Smarty class library files<🎜>
<🎜>$smarty = new Smarty; //Create a new Smarty object<🎜>
<🎜>$cond = 1;<🎜>
<🎜>$smarty->assign("cond",$cond); //Assign values to variables in the template
$smarty->display('test6.htm'); //Display page
?>
|
http://www.bkjia.com/PHPjc/1015341.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1015341.htmlTechArticleSmarty template conditional judgment usage example template file test6.html code in php: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 html head titleSmarty Test/title /head body table width=200...