Home > Backend Development > PHP Tutorial > php—Smarty-7 (24), phpsmarty-724_PHP Tutorial

php—Smarty-7 (24), phpsmarty-724_PHP Tutorial

WBOY
Release: 2016-07-13 09:54:44
Original
897 people have browsed it

php—Smarty-7 (24), phpsmarty-724

3. Methods

l assign : Assign variables to templates

l assignByRef: assign variables to templates (pass by reference)

The difference between

php—Smarty-7 (24), phpsmarty-724_PHP TutorialDisplay and fetch:

4. Filter

Filters are used to filter data

1. Types of filters:

1) Prefilters Prefilters

2) Post filters Postfilters

3) Output Filters

The above three filters are divided into three types according to different triggering times

2. Workflow

tpl source file => Prefilter => Compile tpl file => Postfilter => Save to disk => Execute the compiled php file => Output Filters (=> If there is smart cache, the contents of Output Filters Will be cached) => Result output.

3. Register filter

In Smarty, filters must be registered before they can be used

In 2.6, register filters

l Prefilters

$smarty->register_prefilter(“func”);

l Postfilters

$smarty->register_postfilter(“func”);

l Output Filters

$smarty->register_outputfilter(“func”);

Registering different filters calls different methods.

In 3.0, register filter

$smarty->registerFilter($type, $callback);

$type: filter type

Value range:

Pre: Pre-filter

Post: Post filter

Output: Output filter

$callback: filter function

4. Code:

The pre-filter and post-filter will be executed when compiled for the first time, or will be executed again after the template is changed

The output filter will be executed every time

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/995278.htmlTechArticlephp—Smarty-7 (24), phpsmarty-724 3. Method lassign: Assign the variable lassignByRef to the template: Template allocation variables (passed by reference) The difference between Display and fetch: 4. Filter...
Related labels:
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