Home  >  Article  >  Backend Development  >  Configuration file data and retained data of smarty template engine, smarty template_PHP tutorial

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

WBOY
WBOYOriginal
2016-07-13 09:59:091078browse

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"

3. How to use

Load configuration file: {config_laod file="path"}
Use profile data: 39da2f29233e6c25fc637ce63f8408d0

Example:

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

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/>

2. Obtain post data

How to use it:

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

3. Obtain server data

How to use it:

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

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...
Statement:
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