thinkphp template shows the use of display and assign
Single Assignment
This->assign (' name ', $value); Use the Assign method in the Action class to assign a value to the template variable, regardless of which variable type is uniformly used assign assignment
$this->display ()//Output template file
Batch Assignment
$array [' name '] = ' thinkphp '
$array [' email '] = [email protected] '
$array [' phone '] = ' 12335678 '
$this->assign ($array)
$this->display ()//Call the User module's Read action template
$this->display (' edit ')//Call the User module's edit action template
$this->display (' member:read ')//Call the Read action template of the Member module
$this->display ([email protected]:edit ')//Edit action template of User module calling Xp theme
$this->display ('.. /member/read.html ')//Specify the full name of the template file directly
Template label
{} or {//comment content}//Template comment
{$user [' name ']}//output array variable
{$user: Name}//properties of the Output object
To facilitate template definition, the output template variable can be output in the following uniform way, regardless of whether it is an array or an object:
{$user. Name}
If the output of a multidimensional array or multi-layered object property, use the following definition:
{$user [' Sub '] [' name ']}
{$user: Sub:name}
Using functions:
Format: {$varname |function1|function2=arg1,arg2,###}
Description
There can be no spaces between {and $ symbols, there is no problem with the space behind the argument
# # #表示模板变量本身的参数位置
System variables
{$Think. Server.script_name}//Get $_server variable
{$Think. SESSION.SESSION_ID|MD5}//Get $_session variable
{$Think. Get.pagenumber}//Get $_get variable
{$Think. Cookie.name}//Get $_cookie variable
System constants
{$Think. const.__file__}
{$Think. Const.module_name}
Special variables, constants defined by the thinkphp system
{$Think. Version}//Versions
{$Think. Now}//Current time
Quick output
{: function (...)} Executes the method and outputs the return value
{~function}//execution method does not output
}//Output Session variable
{&var}//Output configuration parameters
{%var}//Output language variable
{. var}//Output GET variable
{^var}//Output POST variable
{*var}//Output constant
Include external files
Use variables to control the template to be imported
Use a full file name that contains