This article mainly introduces the configuration file data and data retention methods of the smarty template engine. The example analyzes the configuration file data of the smarty template engine and the specific techniques for getting data, which has some reference value, for more information, see the example in this article to describe the configuration file data and data retention methods of the smarty template engine. Share it with you for your reference. The details are as follows:
1. how to retrieve data from the configuration file directly
1. application scenarios
When a variable value is not directly written to the program (allocated by smarty), it can be obtained through the configuration file.
2. write the configuration file
Create a 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
Load the configuration file: {config_laod file = "path "}
Use the configuration file data: <{# key #}>
Example:
{config_laod file="my.config"}...
2. how to obtain data with reserved variables
That is, how to obtain get/post/session/server data. The data is saved in the array. smarty encapsulates the method and can be obtained directly through the smarty variable.
1. get data
Traditional method: get data first and distribute it to smarty. However, smarty encapsulates methods and can directly obtain get data without assigning them.
The usage is as follows:
Username: <{$ smarty. get. username}>
Password: <{$ smarty. get. password}>
2. get post data
The usage is as follows:
Username: <{$ smarty. post. username}>
Password: <{$ smarty. post. password}>
3. obtain server data
The usage is as follows:
Server Name: <{$ smarty. server. SERVER_NAME}>
I hope this article will help you with php programming.