Home > Backend Development > PHP Tutorial > Introducing smarty template_PHP tutorial

Introducing smarty template_PHP tutorial

WBOY
Release: 2016-07-20 11:03:42
Original
980 people have browsed it

PHP code:------------------------------------------------- ----------------------------------
The following introduction is based on version 2.5. I don’t know if there are any BUGs. , the OS is win2000, php should be
4.1 or later. , Brother has only used it a few times during development, and has not done too much research.
The introduction can be found in the manual. Please forgive me if there are any mistakes.
The smarty template is said to be recommended by php.net , it is said that the function is relatively strong, and the speed is
not too slow. It is said that more and more people are using it
The official website smarty.php.net has forums, downloads, and manuals. There is everything you want, let’s get to the point:
(-) Installation:
After decompressing the downloaded package, there are three subordinate directories: the template file directory is and there are four class files and one directory under it. First of all Introduce the most important thing: Smarty.class.php. It should be the core class of the entire smarty template. You also deal with it in daily applications. Create the following directory structure in your application directory:
/app_1/smarty/libs
/app_1/smarty/templates_c
/app_1/smarty/templates
/app_1/smarty/configs
Place the class files required by smarty in the libs directory under the corresponding compressed package
Store template files. Template files used by the program are placed here
Store template attribute files, which will be explained in detail later
Store "compiled" template files, which will be detailed later Say, some directories need to be set to 777
to store cached template files
The above file names are smarty’s default file names. Users can specify different file names, such as: guest_template_dir, admin_template_dir, etc. If not Specify that the above file name will be used
(2) Use:
Design template:
1 Template variable: {$variable name}, such as {$color}, {$type}
test_color.tpl
{$name}
test_url.tpl
{$title}
2 You can also use template array
test_array.tpl
{people.name}

{people.sex}

{people.money}

3 template usage block list
such as:
user1 user1_sex user1_money
user2 user2_sex user2_money
user3 user3_sex user3_money
section.tpl
Can be formatted with tables:


{section name=user loop=$userList}




www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445256.htmlTechArticlePHP code:--------------------- -------------------------------------------------- --------- The following introduction is based on version 2.5. I don’t know if there are any bugs. The OS is win2000 and PHP should be version 4.1 or later...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
{$userList[user]. name} {$userList[user].sex}