ThinkPHP5.0 (2) Understanding of MVC (1), introducing controllers, static pages, static constants!

Source: Internet
Author: User

1. First, create a group, of course you can also delete or modify the index of the group, I created a new admin group

2. Under the Controller group, create a new file, unlike ThinkPHP3, ThinkPHP5, simplified the name, do not need to write AdminController.class.php, just write admin.php. Note: Capitalize the first letter!

3. Write the controller first, and notice the namespace!

4. Create the corresponding Controller folder in the view:

5. Introduction of HTML files:

6. First look at the effect! CSS files and JS are not introduced at this time. When entering a URL, you do not have to worry about the controller and other initial capitalization issues, the system will default to all the URLs are converted to lowercase!

7. Introduce CSS styles, pictures, etc.

8. Modify the path in the HTML! CSS and pictures

9. You can define constants in config.php, eliminating the writing of such a long path!

10. Rewrite to:

11. As a result, the HTML also becomes: CSS and pictures

12. Refresh the page, no changes!

13. You can use the introduction of different static pages to try!

ThinkPHP5.0 (2) Understanding of MVC (1), introducing controllers, static pages, static constants!

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.