Configuration file data and retained data of smarty template engine, smarty template_PHP tutorial

WBOY
Release: 2016-07-13 09:59:09
Original
1078 people have browsed it

Configuration file data and retained data of smarty template engine, smarty template

This article describes the configuration file data and retained data methods of smarty template engine through examples. Share it with everyone for your reference. The details are as follows:

1. How to let the template directly retrieve data from the configuration file

1. Usage occasions

When a certain variable value does not want to be written directly into the program (allocated through smarty), it can be obtained through the configuration file.

2. Write configuration file

New folder: config
Create a new file name: my.ini or my.config
Content: key=value;

Example:

title="This is the title of the website."
bgcolor="pink"
Copy after login

3. How to use

Load configuration file: {config_laod file="path"}
Use profile data: <{#key#}>

Example:

{config_laod file="my.config"}
<body bgcolor='<{#bgcolor#}>'>...</body>
Copy after login

2. How to obtain the data of retained variables

That is, how to obtain get/post/session/server data. These data are stored in arrays. Smarty encapsulates methods and can be obtained directly through smarty variables.

1. Obtain get data

Traditional method: get the get data first and then assign it to smarty. But smarty itself encapsulates the method, and you can get the data directly without allocation.

How to use it:

用户名:<{$smarty.get.username}><br/>
密码:<{$smarty.get.password}><br/>
Copy after login

2. Obtain post data

How to use it:

用户名:<{$smarty.post.username}><br/>
密码:<{$smarty. post.password}><br/>
Copy after login

3. Obtain server data

How to use it:

服务器名称:<{$smarty.server.SERVER_NAME}>
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/976028.htmlTechArticleConfiguration file data and retained data of smarty template engine, smarty template This article describes the configuration file data of smarty template engine with examples and methods of retaining data. Share it with everyone for your reference...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template