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

不言
Release: 2023-03-23 12:10:02
Original
1579 people have browsed it

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"
Copy after login

3. Usage method

Load configuration file: {config_laod file="path"}
Use configuration File data: <{#key#}>

Example:

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

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/>
Copy after login

2. Obtain post data

The usage method is as follows:

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

3. Obtain server data

The usage method is as follows:

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

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!

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