thinkphp template shows the use of display and assign

Source: Internet
Author: User
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

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