Thinkphp basics (2) and thinkphp basics. Thinkphp basics (2). thinkphp basics section 1 describes thinkphp basic paths, and Section 2 describes common thinkphp usage (M layer and V layer) we will first create thinkphp basics at the Controller layer (2) and thinkphp basics
Section 1 introduces the basic path of thinkphp, and Section 2 describes common thinkphp usage (layer M and layer V)
We first create an IndexController. class. php file on the Controller layer (the file format is xxxController. class. php, and we recommend that you use uppercase letters). other statements are not recognized as Controller files by the framework.
Create an index function
Assign ('variable', "output variable to template"); // assign is used to output the controller variable to the V layer $ this-> display (); // after the assign is complete, you must display it before it can be output to the template}
Upload File (this name must be consistent with the display function name in the Index controller). enter the following code:
Document {$variable}
{$ Xxx} can output the assign variable in the controller. in this case, enter http: // localhost/your folder name/index. php in the url? M = Home & c = Index & a = index, the word "output variable to template" will appear, so that the output variable is implemented in the template. This is very common !!
Then the second common place is the U function. I function is not described here. For details, see the api documentation.
No display function is rendered to the template. it can be used for Operation logic. if ajax requests an address, the request address is a function of the controller (reflected in url a parameter). other operations are similar to pure php programming.
Thinkphp basics section 1 introduces thinkphp basic path problems. Section 2 describes common thinkphp usage (M layer and V layer). We will first create a new thinkphp on the Controller layer...