Home > Backend Development > PHP Tutorial > Introduction to comments and truncation functions in Smarty, introduction to smarty truncation function_PHP tutorial

Introduction to comments and truncation functions in Smarty, introduction to smarty truncation function_PHP tutorial

WBOY
Release: 2016-07-13 09:57:32
Original
733 people have browsed it

Introduction to annotation and truncation functions in Smarty, introduction to smarty truncation function

Annotation
Copy code The code is as follows:
{* This is a single-line Smarty comment from jb51.net, which cannot be seen in the source code of the web page*}


{* This is a multi-line
Smarty Notes
Not sent to the browser
*}

Template comments are surrounded by asterisks, followed by delimiters, such as: {* This is a comment *}. Smarty comments will not be displayed in the output of the final template, unlike this. The former is useful for inserting internal comments in templates where no one else can see them. ;-)

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

Truncate
Copy code The code is as follows:
$smarty->assign('hxtitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');

The template is:
Copy code The code is as follows:
{$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}

The output is:
Copy code The code is as follows:
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.

You don’t need to intercept it in PHP: http://www.itlearner.com/code/smarty_cn/language.modifier.truncate.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/981350.htmlTechArticleIntroduction to the annotation and truncation functions in Smarty, introduction to the smarty truncation function, comment copy code, the code is as follows: {* This is a The single-line Smarty comment comes from jb51.net and cannot be seen in the source code of the web page...
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