php模板里面如何注释,Smarty中的注释和截断功能介绍

注释

{* 这是一个单行Smarty注释 来自于jb51.net,网页源代码里看不见*}

{* 这是一个多行

Smarty注释

并不发送到浏览器

*}

模板注释由星号包围,继而由分隔符包围,型如:{* 这是一个注释 *}。Smarty注释不会在最终模板的输出中显示,这点和不同。前者对于在模板中插入内部注释有用,因为没有人能看到。;-)

截断truncate

$smarty->assign('hxtitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');

模板为:

{$hxtitle}

{$hxtitle|truncate}

{$hxtitle|truncate:30}

{$hxtitle|truncate:30:""}

{$hxtitle|truncate:30:"---"}

{$hxtitle|truncate:30:"":true}

{$hxtitle|truncate:30:"...":true}

{$hxtitle|truncate:30:'..':true:true}

输出为:

Two Sisters Reunite after Eighteen Years at Checkout Counter.

Two Sisters Reunite after Eighteen Years at Checkout Counter.

Two Sisters Reunite after...

Two Sisters Reunite after

Two Sisters Reunite after---

Two Sisters Reunite after Eigh

Two Sisters Reunite after E...

Two Sisters Re..ckout Counter.

可以不用在PHP里截取了:http://www.itlearner.com/code/smarty_cn/language.modifier.truncate.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值