Home >Backend Development >PHP Tutorial >PHP simple smarty entry program example_PHP tutorial
First there are 3 folders configs, templates, templates_c. There is a configuration file in the configs folder: test.conf, code:
3 4
|
[setup] bold = true
|
1 2 3 4 5 6 |
require 'libs/Smarty.class.php'; //包含Smarty类库文件 $smarty = new Smarty; //创建一个新的Smarty对象 $smarty->assign("Name","Simon"); //对模版中的变量赋值 $smarty->display('test.htm'); //显示页面 ?> |
1
4
5
|
Hello, {$Name} |
1 2 3 4 5 6 | <🎜>require 'libs/Smarty.class.php'; //Contains Smarty class library files<🎜> <🎜>$smarty = new Smarty; //Create a new Smarty object<🎜> <🎜>$smarty->assign("Name","Simon"); //Assign values to variables in the template $smarty->display('test.htm'); //Display page ?> |
1 2 3 4 5 6 7 8 |
Hello, Simon |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<🎜>/* Smarty version 2.6.22, created on 2009-03-19 13:20:00<🎜>
<🎜>compiled from test.htm */<🎜>
<🎜>?>
Hello, _tpl_vars['Name']; ?> |
This file is the effect displayed when browsing.