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

Configuration file data and retained data of smarty template engine

不言
不言Original
2018-04-09 16:30:071578browse

This article mainly introduces the configuration file data of smarty template engine and the method of retaining data. It analyzes the configuration file data of smarty template engine and the specific techniques for obtaining data with examples. It has certain reference value. Friends who need it 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, no If you want to program it directly (distributed through smarty), you can get it through the configuration file.

2. Write configuration file

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

Example:

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

3. Usage method

Load configuration file: {config_laod file="path"}
Use configuration File data: 39da2f29233e6c25fc637ce63f8408d0

Example:

{config_laod file="my.config"}
<body bgcolor=&#39;<{#bgcolor#}>&#39;>...</body>

2. How to obtain the 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 get data directly without allocation.

The usage method is as follows:

用户名:<{$smarty.get.username}><br/>
密码:<{$smarty.get.password}><br/>

2. Obtain post data

The usage method is as follows:

用户名:<{$smarty.post.username}><br/>
密码:<{$smarty. post.password}><br/>

3. Obtain server data

The usage method is as follows:

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

The above is the detailed content of Configuration file data and retained data of smarty template engine. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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