Configuration file data and retention data of the smarty template engine

Source: Internet
Author: User
Tags smarty template

Configuration file data and retention data of the smarty template engine

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

 

 

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:

?

1

2

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:

?

1

2

{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:

?

1

2

Username: <{$ smarty. get. username}> <br/>

Password: <{$ smarty. get. password}> <br/>

2. Get post Data

The usage is as follows:

?

1

2

Username: <{$ smarty. post. username}> <br/>

Password: <{$ smarty. post. password}> <br/>

3. Obtain server data

The usage is as follows:

?

1

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.