Thinkphp template output tips

Source: Internet
Author: User
This article mainly introduces thinkphp template output techniques. Examples summarize the commonly used output techniques such as variable output, system variables, and operators, which are very useful. For more information, see

This article mainly introduces thinkphp template output techniques. Examples summarize the commonly used output techniques such as variable output, system variables, and operators, which are very useful. For more information, see

This example summarizes the thinkphp template output skills. Share it with you for your reference. The details are summarized as follows:

I. Variable output (emphasis)

1. scalar output:

The Code is as follows:

{$ Name}

2. array output

The Code is as follows:

{$ Name [0]}
{$ Name ['k2']}
{$ Name. k1}


3. Object output

The Code is as follows:

{$ Name: k} // call the member attribute K of this object
{$ Name-> k} // call the K Method


Ii. System Variables

The Code is as follows:

{$ Think. get. id} // call the system variable in the template to obtain the provided id value.

3. Use Functions

The Code is as follows:

The compiled file {$ name | strtoupper} is

{$ Name | date = 'y m d H: I: s', ###} // All # indicates the point, representing the previous variable $ name

Iv. Default Value

The Code is as follows:

{$ Name | default = 'default here '} // use the default value if the value does not exist

5. Operators

The Code is as follows:

// Common operators: +-*/% + + --
{$ Name + 1}

I hope this article will help you with ThinkPHP framework programming.

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.