test.php Code:
| 1 2 3 4 5 6 7 8 9 |
<?php require ' libs/smarty.class.php '; Contains the Smarty class library file $smarty = new Smarty; Create a new Smarty object $total = 12345; The $total assignment $smarty->assign ("Total", $total); Assign values to variables in a template $formatted _total = Number_format ($total); Format $total $smarty->assign ("Formatted_total", $formatted _total); Assign values to the variables in the template $smarty->display (' test1.htm '); Display Page?> |
Test1.html Template code:
Compiled test.html.php code:
| 1 2 3 4 5 6 7 8 9 10 11 12-13 |
<?php/* Smarty version 2.6.22, created on 2009-03-19 14:37:39-compiled from test1.htm/?> |
test1.html templates can be rewritten as such test2.html:
The corresponding test.php code is changed to:
| 1 2 3 4 5 6 7 |
<?php require ' libs/smarty.class.php '; Contains the Smarty class library file $smarty = new Smarty; Create a new Smarty object $total = 12345; $smarty->assign ("Total", $total); Assign values to the variables in the template $smarty->display (' test2.htm '); Display Page?> |
Browser display:
Total is 12345
Formatted Total is 12,345
I hope this article will help you with your PHP program design.