fetch的区别:

search
Homephp教程php手册php—Smarty-7(24),phpsmarty-724

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

三、            方法

l  assign      :为模板分配变量

l  assignByRef :为模板分配变量 (按引用传递)

Display和fetch的区别:

 

四、            过滤器

过滤器就是用于过滤数据

1、过滤器的种类:

1)预过滤器           Prefilters

2)后过滤器             Postfilters

3)输出过滤器         Output Filters

根据触发时间的不同,划分出以上三种过滤器

2、工作流程

tpl源文件 =〉Prefilter =〉编译tpl文件 => Postfilter =>保存到磁盘=> 编译过的php文件执行=〉Output Filters(=〉如果有smarty cache的话,Output Filters的内容会缓存) =>结果输出。

3、注册过滤器

 

在Smarty中,过滤器在使用之前必须注册

 

在2.6中,注册过滤器

l  Prefilters

       $smarty->register_prefilter(“func”);

l  Postfilters

       $smarty->register_postfilter(“func”);

l  Output Filters

       $smarty->register_outputfilter(“func”);

注册不同的过滤器调用不同的方法。

3.0中,注册过滤器

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

$type:过滤器类型

            取值范围:

           Pre:预过滤器

           Post:后过滤器

           Output :输出过滤器

$callback:过滤器函数

4、代码:

预过滤和后过滤器第一次编译时会执行,或者模板发生改变后会再次执行

输出过滤器每次都会执行

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor