Configuration file data and retention data of the smarty template engine, smarty Template
This document describes 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"}<body bgcolor='<{#bgcolor#}>'>...</body>
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}> <br/> password: <{$ smarty. get. password}> <br/>
2. Get post Data
The usage is as follows:
Username: <{$ smarty. post. username}> <br/> password: <{$ smarty. post. password}> <br/>
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.