首页 >

php—Smarty-7(24)

后端开发|php教程php—Smarty-7(24)
nbsp,smarty,Output,Filters,register
后端开发-php教程
C、 方法
微模板源码下载,vtk需要vscode么,装ubuntu后,tomcat本地访问项目,sqlite3 临时文件,小学毕业能学会计算机爬虫吗,php循环日期,沈阳seo推广优质团队,网上下载的网站模板怎么用,网站静态首页模板lzw
l assign :为模板分配变量
美丽播直播系统源码,vscode自定义背景图,ubuntu共享桌面,tomcat8深入剖析,爬虫工具库,php 动态创建函数,学seo好还是web渗透好lzw
l assignByRef :为模板分配变量 (按引用传递)
asp聊天室网站源码,vscode实现ssh,ubuntu lingo,tomcat 安全管理,sqlite 外部数据库,discuz 插件的名称修改,前端ui框架h5,爬虫和数据挖掘的区别,html5源码 php,福建公司seo价格,网站如何更换图片,网页做魔方效果,discuz模板目录结构lzw
php—Smarty-7(24)

l append :追加模板变量到一个数组中

php—Smarty-7(24)

l appendByRef :追加模板变量到一个数组中 (按引用传递)

php—Smarty-7(24)

l clearAllAssign

清除所有已赋值变量

php—Smarty-7(24)

l clearCache

清除缓存

l configLoad 加载配置文件

在smarty中,加载配置文件两种方法:

1)在模板中 {config_load file=’….’}

2)在程序中 $smarty->configLoad($file[,$section])

l clearConfig

清除所有配置文件变量

l display

读取、替换、输出

l fetch

读取、替换、返回

l templateExists :判断模板是否存在

php—Smarty-7(24)

尝试加载一个不存在的模板会报错,在显示之前应该判断

assign和assignByRef的区别:

php—Smarty-7(24)

Display和fetch的区别:

php—Smarty-7(24)

D、 过滤器

过滤器就是用于过滤数据

1、过滤器的种类:

1)预过滤器 Prefilters

2)后过滤器 Postfilters

3)输出过滤器 Output Filters

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

2、工作流程

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

php—Smarty-7(24)

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

php—Smarty-7(24)

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

输出过滤器每次都会执行

以上就介绍了php—Smarty-7(24),包括了方面的内容,希望对PHP教学有兴趣的朋友有所帮助。


php—Smarty-7(24)
  • register_globals使用详解
  • register_globals使用详解 | register_globals使用详解 ...

    php—Smarty-7(24)
  • 关于 Register Globals开启后会遇到的有关问题
  • 关于 Register Globals开启后会遇到的有关问题 | 关于 Register Globals开启后会遇到的有关问题 ...

    php—Smarty-7(24)
  • 利用 htaccess 打开 / 关闭 register_globals 及 magic_quotes_gpc
  • 利用 htaccess 打开 / 关闭 register_globals 及 magic_quotes_gpc | 利用 htaccess 打开 / 关闭 register_globals 及 magic_quotes_gpc ...