I. Output of thinkphp 3 (emphasis)
A, through the Echo and other PHP native output mode in the page output
B. You can use the Assign method to output the variable you want to assign by using the Display method
Public Function Index () {$name = "Pandanus"; $this->assign (' name ', $name); Assign the $name to the variable name so that the template gets $this->display (); }
Template get
Create a module folder under the corresponding TPL (note case), create HTML for the corresponding method name
1 2 3 <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">4 <title>insert title here</title>5 6 < body>7 Hello world,{$name}8 </body>9 To avoid conflicts, it is recommended that you modify the delimiter for the output of the configuration item below
' Tmpl_l_delim ' = ' <{',//Modify left delimiter ' tmpl_r_delim ' = '}> ',//Modify right delimiter
<body> Hello world,<{$name}></body>
C, modify the left and right delimiter Hugh to modify configuration items in the configuration file ' Tmpl_l_delim ' + ' <{',//Modify the left delimiter ' tmpl_r_delim ' + '}> ',//modify the correct delimiter
Ii. model use of thinkphp 3 (emphasis)
You need to manipulate the database in a method by using the new Model (table name)
Public Function Index () { $m =new Model (' user '); In config.php configuration, call the user table $arr = $m->select (); Query Var_dump ($arr); }
Setting up Database information in config.php
' Db_type ' = ' mysql ',//Set Database type ' db_host ' = ' localhost ',//Set host ' db_name ' + ' thinkphp ',//Set database name ' db_user ' + = ' Root ',//Set user name ' Db_pwd ' + ',//Set password ' db_port ' = ' 3306 ',//Set port number ' Db_prefix ' + ' tp_ ',//Set table prefix
You can also use the following configuration equivalent
' Db_dsn ' + ' Mysql://root: @localhost: 3306/thinkphp ', //Configure database information using DSN mode, simplify database configuration ' db_prefix ' = ' tp_ ',// Set Table prefixes
If both methods are present, the DSN is preferred
Thinkphp Learning