Home > Backend Development > PHP Tutorial > smarty 的truncate详细用法。该怎么处理

smarty 的truncate详细用法。该怎么处理

WBOY
Release: 2016-06-13 13:46:59
Original
895 people have browsed it

smarty 的truncate详细用法。。。。。
请教:

smarty 的truncate 的用法是怎样的?怎么我想截取的字符长度与实际截取出的相差那么远??

模板部分代码:
{$title|truncate:15}


PHP处理程序部分代码:
$smarty->assign("title","what will you do if you had more money?");

怎么显示出来的是:what will...

不是截取15个字符吗?

谢谢。。

------解决方案--------------------
默认情况下,smarty会截取到一个词的末尾。
如果你想要精确的截取多少个字符,把第三个参数改为"true"

HTML code
{$title|truncate:15:"...":true} <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template