Smarty Truncate intercept string//In SQL Truncate is delete table (truncate is delete content only, deletedeletes completely )
Intercepts a length of characters from the beginning of a string, with a default length of 80
Specifies the length of the second argument as the Intercept string
By default, Smarty is truncated to the end of a word,
If the exact number of characters to intercept can be used, use the third parameter to set it to "true"
The specific usage is as follows:
Copy CodeThe code is as follows:
index.php $smarty = new Smarty;
$smarty->assign (' ArticleTitle ', ' both 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}
Output Result:
Sisters reunite after eighteen years at Checkout Counter.
Sisters reunite after eighteen years at Checkout Counter.
Sisters reunite after ...
Sisters reunite after
Sisters Reunite After-
Sisters reunite after Eigh
Sisters reunite after E ...
"PHP Project" "Smarty" Smarty intercept string method truncate