Example of using the smarty template condition judgment in php. In php, the smartytemplates' condition checking method is used to determine the usage of the smarty template condition in the template file test6.html code: 123456789101112131415161718htmlheadtitleSmartyTesttitleheadbodytablewidth200 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}
| Condition is true |
| The condition is not true. |
|
Php code:
|
1
2
3
4
5
6
7 |
Require 'libs/Smarty. class. php'; // contains the Smarty class library file
$ 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
?>
|
Example template file test6.html code: 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...