Method for concatenating strings in the smarty Template

Source: Internet
Author: User
Tags smarty template

Method for concatenating strings in the smarty Template

This article describes how to concatenate strings in the smarty template. For more information, see

Variables uploaded to the Smarty template on the PHP page (here, two variables are created on the Smarty)

 

The Code is as follows:

{Assign var = "name" value = 'Richard. Lil '}

{Assign var = "age" value = '27 '}

 

 

1. output in a certain position of the Smarty template (Richard. Lee --- 27)

Splicing method: {$ name | cat: "---" | cat: $ age}

Explanation: concatenates variables $ name, "---", and $ age into a string.

 

2. If you want to output (Name: Richard. Lee, age: 27) somewhere in the Smarty template, the splicing method is as follows:

Copy the Code as follows:

{"Name:" | cat: $ name | cat: ", age:" | cat: $ age}

{"Name:" | cat: $ name | cat: "," | cat: "age:" | cat: $ age}

 

 

Explanation: The two splicing methods have the same effect.

 

Note: The method found on the Internet is not very understandable | cat:, but after two simple examples, it is concluded that | cat: can be considered as a symbolic link string, it is equivalent to the point (.) in the PHP file (.).

 

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.