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.