Introduction to the annotation and truncation functions in Smarty, Introduction to the smarty truncation function _ PHP Tutorial

Source: Internet
Author: User
Description of the annotation and truncation functions in Smarty, and description of the smarty truncation function. Description of the annotation and truncation functions in Smarty. description of the smarty truncation function the annotation copying code is as follows: {* This is a single line of Smarty annotation from jb51.net. the annotation and truncation functions in Smarty cannot be seen in the source code of the webpage, introduction to the smarty truncation function

Note
The code is as follows:
{* This is a single line of Smarty annotation from jb51.net, which is invisible in the source code of the webpage *}


{* This is a multiline
Smarty comments
Not sent to the browser
*}

Template comments are surrounded by asterisks and then surrounded by delimiters. type: {* This is a comment *}. The Smarty annotation is not displayed in the output of the final template. The former is useful for inserting internal comments in the template, because no one can see it .; -)

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

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

Template:
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}

Output:
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 have to truncate it in PHP: http://www.itlearner.com/code/smarty_cn/language.modifier.truncate.html

Pipeline annotation code is as follows: {* This is a single line of Smarty annotation from jb51.net, which is invisible in the source code of the webpage...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.