Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use smarty template engine to configure and retain data

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "how to use smarty template engine configuration file data and retain data". In daily operation, I believe many people have doubts about how to use smarty template engine configuration file data and retain data. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "how to use smarty template engine configuration file data and retain data". Next, please follow the editor to study!

The details are as follows:

First, how to make the template extract data directly from the configuration file

1. Use occasion

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

two。 Write configuration file

Create a new folder: config

Create a new file name: my.ini or my.config

Content: key=value

Example:

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

3. Usage

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

Use profile data:

Example:

{config_laod file= "my.config"}.

Second, how to obtain the data of reserved variables

That is, how to get get/post/session/server data. This data is stored in an array, and smarty encapsulates the method, which can be obtained directly through the smarty variable.

1. Get get data

The traditional way is to get get data first, and then assign it to smarty. But smarty itself encapsulates the method, and you can get get data directly without allocation.

The method of use is as follows:

User name: password:

two。 Get post data

The method of use is as follows:

User name: password:

3. Get server data

The method of use is as follows:

Server name: at this point, the study on "how to use the smarty template engine to configure file data and retain data" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report