欢迎来到代码驿站!

PHP代码

当前位置:首页 > 软件编程 > PHP代码

Smarty中的注释和截断功能介绍

时间:2021-02-05 09:28:29|栏目:PHP代码|点击:

注释

复制代码 代码如下:

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


{* 这是一个多行
   Smarty注释
   并不发送到浏览器
*}

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

http://www.itlearner.com/code/smarty_cn/language.basic.syntax.html

截断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

上一篇:php运行报错Call to undefined function curl_init()的最新解决方法

栏    目:PHP代码

下一篇:PHP 杂谈《重构-改善既有代码的设计》之一 重新组织你的函数

本文标题:Smarty中的注释和截断功能介绍

本文地址:http://www.codeinn.net/misctech/57227.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有