How to stitch strings in Smarty templates _php tutorial

Source: Internet
Author: User
Tags smarty template
PHP page to the variable on smarty template (used here, create two variables on Smarty instead)
Copy CodeThe code is as follows:
{Assign var= "name" Value= ' Richard.lee '}
{Assign var= "age" value= ' 27 '}


1. Want to output at a location in the Smarty template (Richard.lee---27)
Stitching method: {$name |cat: "---" |cat: $age}
Explanation: Splicing variables $name, "---", $age into a string

2, want to output in a location of smarty template (name: Richard.lee, Age: 27), stitching method:
Copy CodeThe code is as follows:
{"Name:" |cat: $name |cat: ", Age:" |cat: $age}
{"Name:" |cat: $name |cat: "," |cat: "Age:" |cat: $age}

Explanation: Two stitching methods get the same effect

Note: The method found on the web is not very understanding |cat: the role, but after two simple examples to draw a simple conclusion: you can put |cat: as a link string symbol, equivalent to the point in the php file (.).

http://www.bkjia.com/PHPjc/825259.html www.bkjia.com true http://www.bkjia.com/PHPjc/825259.html techarticle the PHP page is uploaded to the variable on the Smarty template (here, create two variables on smarty) to copy the code as follows: {Assign var= "name" Value= ' Richard.lee '} {assign var= "age" V ...

  • 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.