PHP code :--------------------------------------------------------------------------------
The introduction below is based on version 2.5, and I do not know if there is a BUG. the OS is win2000, and php should
4.1 and later ., I used it several times during development, but I didn't study it too deeply,
The introduction can be found in the manual. If there is any error, it is inevitable that I will not be sorry.
The smarty template is said to be recommended by php.net. It is said that it has strong functions and is said to be fast.
It is said that more and more people are using
The official website smarty.php.net contains forums, downloads, and manuals. If you have everything you want, go to the topic:
(-) Installation:
After the downloaded package is decompressed, there are three sub-directories: The template file directory is a directory of four class files under <libs>. first, we will introduce the most important: Smarty. class. php should be the core class of the whole smarty template. It is also used to deal with it in normal times. The following directory structure is created under your application directory:
/App_1/smarty/libs
/App_1/smarty/templates_c
/App_1/smarty/templates
/App_1/smarty/configs
<Libs> put the class files required by smarty under the libs directory of the corresponding compressed package
<Templates> store template files. All template files used by the program are stored here.
<Configs> stores the module attribute file, which will be detailed later.
<Templates_c> store the "compiled" template file. Later, we will detail that some directories need to be set to 777.
<Cache> Save the cached Template File
The above file name is the default file name of smarty. You can specify different file names, such as guest_template_dir and admin_template_dir. If not specified, the above file name will be used.
(2) usage:
Design template:
1 template variable: {$ variable name}, for example, {$ color}, {$ type}
Test_color.tpl
<Font color = {$ color}> {$ name} </font>
Test_url.tpl
<A href = "{$ url}" target = "{$ target}" >{$ title} </a>
2. You can also use a template array.
Test_array.tpl
{People. name} <br>
{People. sex} <br>
{People. money} <br>
3. List of blocks used by the Template
For example:
User1 user‑sex user‑money
User2 user2_sex user2_money
User3 user3_sex user3_money
Section. tpl
You can format the table:
<TABLE>
{Section name = user loop = $ userList}
<TR>
<TD >{$ userList [user]. name} </TD>
<TD >{$ userList [user]. sex} </TD>