Thinkphp built-in template engine is a self-innovative XML-compiled template engine, below a case to share some thinkphp built-in template engine commonly used template tag usage, including variable output, loop, judgment, comparison, etc., these are relatively basic usage, All tags and features of the thinkphp built-in template engine cannot be included.
(1) The following is the Controller Indexaction class source code
1, ' name ' = ' thinkphp ', ' email ' = ' liu21st@gmail.com '); $this->assign (' Vo ', $vo); $obj = (object) $vo; $this->assign (' obj ', $obj); $this->assign (' array ', Array (5,260,13,7,40,50,2,1)); $this->assign (' Num1 ', 6); $this->assign (' num2 ', 2); $this->assign (' num ', 6); $this->display (); }} ?>
(2) The following is a demonstration of the above controller assignment to the template of some variables, constants and some basic usage of the array
Universal variable Output
num1:{$num 1}
Object output
id:{$obj: ID}
name:{$obj: Name}
Array output
id:{$vo [' ID ']}
name:{$vo [' Name ']}
Automatically determine array and object output
id:{$vo. ID}
name:{$vo. Name}
System constant output (System constants can be used without assign assignment in the controller)
{$Think. now|date= ' y-m-d h:i:s ', # # #}
{$Think. Server.php_self}
{$Think. Session.name}
Use a function on a variable (this can be a built-in function or a custom function)
{$vo. Name|strtolower|ucwords}
Foreach output
{$key}:{$item}
The following example uses a loop label, a switch label, a comparison label
[{$i}]
Even rows
Odd rows
{$val} is greater than 5
{$val} is greater than 15
{$val} less than 10
Data {$val}
Data {$val}
Data {$val}
Other data is {$val}
The output is similar to the following:
[1] Odd line 5 less than 10 length is 1
[2] Even line 260 greater than 5 260 is greater than 15 length is 3
[3] Odd line 13 greater than 5 length is 2
[4] Even line 7 is greater than 5 7 less than 10 length is 1
[5] Odd line 40 greater than 5 40 is greater than 15 length 2
[6] Even line 50 greater than 5 50 is greater than 15 length is 2
[7] Odd line 2 less than 10 length is 1
[8] Even line 1 less than 10 length is 1
Thinkphp built-in template engine comparison tab
Greater than 3
Less than 3
The output is similar to the following:
Greater than 3
Less than 3
Conditional judgment
{$num} is greater than 5
{$num} is greater than 3
Other {$num}
The output is similar to the following:
6 Greater than 5
Articles you may be interested in
- The last record in the thinkphp template that determines the volist loop
- Summary of System variables commonly used in thinkphp templates
- thinkphp page Jump (successerror) How to set the jump wait time
- A summary of query techniques in thinkphp
- Full analysis of Adslcfui shortcut method for thinkphp internal function
- thinkphp how to turn off caching
- PHP Statistics search engine access record
- thinkphp print the last SQL statement
http://www.bkjia.com/PHPjc/764131.html www.bkjia.com true http://www.bkjia.com/PHPjc/764131.html techarticle The thinkphp built-in template engine is an independent, innovative XML-compiled template engine that shares some of the usage of template tags commonly used by thinkphp built-in template engines, including ...