Thinkphp basics (2) and thinkphp basics _ PHP tutorials

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

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.