thinkphp Frame Construction Experience

Source: Internet
Author: User
through a week of study, a simple introduction of PHP and thinkphp, and the original learning SSH as a registration and login as a test, write down the experience it.

I do feel that the PHP framework is much faster than SSH, mainly embodied in the thinkphp it all set the system directory structure, MVC has its own directory, respectively, to write each part. and SSH light configuration will be configured for a long time, there are very annoying XML, a long time to make a login example, feel the need to learn a lot of things look like.

When the novice builds the thinkphp, must pay attention to the directory structure. Generally is two modules, under Application, a home an admin. Each module will have a controller, a controller corresponding to the view of a folder, the Controller method may correspond to the view of the corresponding folder of several HTML, and the name and method of the same names, so call $this->display () will call the corresponding view by default. Model is used to define the business logic, if only the simple curd operation of the database is involved, or even the model layer is not defined, or the layer only needs to write things that are automatically validated and populated.

Toggle Relationship: The view layer is usually href and form, note the address of the wording, if the link can be written: Register the function, transfer to the Reg controller's Reg method. If it is a form, you can write this: action= "Createfriend", corresponding to the Createfriend method of the same controller. In addition to the controller if the jump, you can write so $this->success ("registered Success", U (' Index/index '), 5), the importance of the visible U function. Try not to use relative paths, because there are default modules in the framework, default controllers, default methods, and so on, which can cause URLs to be written in multiple ways, and their relative paths will be garbled.

Also, if you want to use the same variable for different methods in the same controller, you can use the session variable, and combine the $this->assign and display methods to achieve the desired effect.

After entering the door, want to drop in the codeignity framework, the College server under the many sites are used this, can learn.


The above describes the thinkphp framework building experience, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

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