PHP头条
热点:

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、代码:

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

输出过滤器每次都会执行

www.phpzy.comtrue/php/36612.htmlTechArticlephp—Smarty-7(24),phpsmarty-724 三、方法 lassign:为模板分配变量 lassignByRef:为模板分配变量(按引用传递) Display和 fetch的区别: 四、过滤器 过滤器就是用于过滤数据 1、过滤器的种类...

相关文章

PHP之友评论

今天推荐