源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

解析smarty 截取字符串函数 truncate的用法介绍

  • 时间:2022-08-15 01:21 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:解析smarty 截取字符串函数 truncate的用法介绍
[b]smarty truncate 截取字符串 [/b]从字符串开始处截取某长度的字符,默认的长度为80 指定第二个参数作为截取字符串的长度 默认情况下,smarty会截取到一个词的末尾, 如果需要精确到截取多少个字符可以使用第三个参数,将其设为”true” [b]具体用法如下: [/b]
[u]复制代码[/u] 代码如下:
//index.php $smarty = new Smarty; $smarty->assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.'); $smarty->display('index.tpl'); //index.tpl {$articleTitle} {$articleTitle|truncate} {$articleTitle|truncate:30} {$articleTitle|truncate:30:""} {$articleTitle|truncate:30:"---"} {$articleTitle|truncate:30:"":true} {$articleTitle|truncate:30:"...":true}
[b]输出结果: [/b]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…
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部