PHP模板变量处理与流程控制语句.pdfVIP

  • 0
  • 0
  • 约2千字
  • 约 4页
  • 2025-12-30 发布于北京
  • 举报

变量:PHPassign(),分配普通数据、数组、对象配置文件的数据Smarty的保

留变量:now、config、const等Php请求变量(http请求时携带的数据):get、

post、s、session、SERVER

变量调节器

_

对模板变量的格式进行修饰dateformat:%Y‑%m‑%d%H:%M:%S

capitalize:首字母大写upperlowerdefault:,默认值escape:转码(默认是实

体转码‑‑→)script/script如果将来需要将实体符号成html的:

__

htmlentitydecode()url转码:url地址栏传输中文、特殊符号时

truncate:截取的字符串长度,截取使用什么字符代码

模板中流程语句、函数

{foreach}

{/foreach}

{if}

{elseigf}

{else}

{/if}

包含

模板继承

继承块

字面量:原封不动输出,不适用smarty解析

变量:

PHPassign(),分配普通数据、数组、对象

配置文件的数据

Smarty的保留变量:now、config、const等

Php请求变量(http请求时携带的数据):get、post、s、session、SERVER

变量调节器

对模板变量的格式进行修饰

date_format:%Y-%m-%d%H:%M:%S

capitalize:首字母大写

upper

lower

default:,默认值

escape:转码(默认是实体转码--→)script/script

如果将来需要将实体符号成html的:html_entity_decode()

url转码:url地址栏传输中文、特殊符号时

truncate:截取的字符串长度,截取使用什么字符代码

模板中流程语句、函数

{foreach}

{/foreach}

{if}

{elseigf}

{else}

{/if}

Include

模板继承

Extends

Block

Literal:原封不动输出,不适用smarty解析

只需要3个步骤:$smarty‑

caching=true$smarty‑

setCacheDir()$smarty‑

_

cachelifetime=60

局部不缓存:{insertname=”函数”键=值}

Smarty/plugins目录下定义函数文件:insert.函数名.php函

__

数命名:smartyinsert函数名

单模板多缓存显示

(temp.html,$id)

判断是否有缓存文件时:Is_

cached(‘temp.html’,$id)

只需要3个步骤:

$smarty-caching=true

$smarty-setCacheDir()

$smarty-cache_lifetime=60

局部不缓存:

{insertname=”函数”键=值}

Smarty/plugins目录下定义函数文件:insert.函数名.php

函数命名:smarty_insert_函数名

单模板多缓存

disy(‘temp.html’,$id)

判断是否有缓存文件时:

Is_cached(‘temp.html’,$id)

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档