Home > Backend Development > PHP Tutorial > Configuration file data and retained data of smarty template engine_PHP tutorial

Configuration file data and retained data of smarty template engine_PHP tutorial

WBOY
Release: 2016-07-13 09:58:54
Original
894 people have browsed it

Configuration file data and retained data of smarty template engine

This article mainly introduces the configuration file data and retained data method of smarty template engine, and analyzes the smarty template engine with examples. Configuration file data and specific techniques for obtaining data have certain reference value. Friends in need can refer to it

The example in this article describes the configuration file data of smarty template engine and the method of retaining data. Share it with everyone for your reference. The details are as follows:

1. How to let the template directly retrieve data from the configuration file

1. Usage occasions

When a certain variable value does not want to be written directly into the program (allocated through smarty), it can be obtained through the configuration file.

2. Write configuration file

New folder: config
Create a new file name: my.ini or my.config
Content: key=value;

Example:

?

1

2

title="This is the title of the website."

bgcolor="pink"

1 2

title="This is the title of the website."


bgcolor="pink"

3. How to use

Load configuration file: {config_laod file="path"}

1

2

{config_laod file="my.config"}

...

Use profile data: <{#key#}> Example:

?

1

2

{config_laod file="my.config"}

...

1

2

用户名:<{$smarty.get.username}>

密码:<{$smarty.get.password}>

2. How to obtain data of retained variables

That is, how to obtain get/post/session/server data. These data are stored in arrays. Smarty encapsulates methods and can be obtained directly through smarty variables.

1. Obtain get data

Traditional method: get the get data first and then assign it to smarty. But smarty itself encapsulates the method, and you can get the data directly without allocation.

How to use it:

1

2

用户名:<{$smarty.post.username}>

密码:<{$smarty. post.password}>

?

1

2

Username: <{$smarty.get.username}>

Password: <{$smarty.get.password}>

1

服务器名称:<{$smarty.server.SERVER_NAME}>

2. Obtain post data How to use it:

?
1 2 Username: <{$smarty.post.username}>
Password: <{$smarty. post.password}>
3. Obtain server data How to use it: ?
1 Server name: <{$smarty.server.SERVER_NAME}>
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/976539.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/976539.htmlTechArticleConfiguration file data and retained data of smarty template engine This article mainly introduces the configuration file data and retention data of smarty template engine Method of retaining data, example analysis of smarty template engine configuration...
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