Configuration file data and retention data of the smarty template engine _ php instance

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.