Php simple smarty entry program instance. Php simple smarty entry program instance requires three folders: configs, templates, and templates_c. in the configs folder, there is a configuration file: test. conf, code: 1234 titleW php simple smarty entry program instance.
First, you must have three folders: configs, templates, and templates_c. in the configs folder, there is a configuration file: test. conf. the code is as follows:
|
1
2
3
4 |
Title = Welcome to Smarty!
Cutoff_size = 40
[Setup]
Bold = true
|
Templates has the template file test.htm:
|
1
2
3
4
5
6
7
8 |
Smarty Test
Hello, {$ Name}
|
Php file code:
|
1
2
3
4
5
6 |
Require 'libs/Smarty. class. php'; // contains the Smarty class library file
$ 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
?>
|
Page code displayed after running:
|
1
2
3
4
5
6
7
8 |
Smarty Test
Hello, Simon
|
After running, a PHP file is generated in the templates_c folder:
|
1
2
3
4
5
6
7
8
9
10
11
12
13 |
/* Smarty version 2.6.22, created on 13:20:00
Compiled from test.htm */
?>
Smarty Test
Hello, _ Tpl_vars ['name'];?>
|
This file shows the effect of browsing.
Token must first have three folders: configs, templates, and templates_c. in the configs folder, there is a configuration file: test. conf, code: 1 2 3 4 title = W...