Home > Backend Development > PHP Tutorial > Examples of usage of smarty template conditional judgment in php_PHP tutorial

Examples of usage of smarty template conditional judgment in php_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 09:50:57
Original
767 people have browsed it

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

910 11 12 13 14 15
16
17
18
Smarty Test {if $cond == 1} {else} {/if}
Condition established
The condition is not met
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...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template