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、代码:
预过滤和后过滤器第一次编译时会执行,或者模板发生改变后会再次执行
输出过滤器每次都会执行

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

WebStorm Mac version
Useful JavaScript development tools
