Smarty Template engine configuration file data and retention data, Smarty template _php Tutorial

Source: Internet
Author: User
Tags smarty template

Smarty Template engine profile data and retention data, smarty templates


The examples in this article describe the configuration file data and methods of preserving data for the Smarty template engine. Share to everyone for your reference. Specific as follows:

How to get the template to remove data directly from the configuration file

1. Use Cases

When a variable value is not expected to be directly written to the program (allocated via Smarty), it can be obtained through the configuration file.

2. Write the configuration file

New 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. How to use

Load configuration file: {config_laod file= "path"}
Using configuration file data: <{#键 #}>

Example:

{config_laod file= "My.config"} ...

Second, how to obtain the data of the reserved variable

That is, how to obtain get/post/session/server data. The data is stored in an array, and Smarty encapsulates the method, which can be obtained directly from the Smarty variable.

1. Get the Get Data

Traditional way: Obtain get data first, then assign to Smarty. But the smarty itself encapsulates the method, without assigning it, to get the get data directly.

Here's how to use it:

User name: <{$smarty .get.username}>
Password: <{$smarty .get.password}>

2. Get Post Data

Here's how to use it:

User name: <{$smarty .post.username}>
Password: <{$smarty. post.password}>

3. Obtaining Server Data

Here's how to use it:

Server name: <{$smarty .server.server_name}>

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/976028.html www.bkjia.com true http://www.bkjia.com/PHPjc/976028.html techarticle smarty profile data and retention data for the template engine, Smarty template This article describes the configuration file data for the Smarty template engine and how to preserve the data. Share for everyone to join us ...

  • 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.