thinkphp Frame Empty Controller

Source: Internet
Author: User

Home represents the module front desk can be used with the admin Model View Controller referred to as MVC

The model is that the data models are primarily dealing with the database and the view represents the module controller that is displayed

The MVC pattern has to follow the rules rather than the configuration.

thinkphp in the common folder is the TP framework comes with some functions conf folder convertion.php contains TP all configuration try not to modify the Lang language Pack Library storage is the core class files, in which the Think folder The controller.class.php is the parent of all the controllers in the class file containing many

Now I have a MainController.class.php file in the config file of the Conf folder under the Home folder, which has a method of test, and this test wants to show a template, Then I will go to the View folder to build a folder is and Maincontroller is corresponding to this folder should be named Main, (I built a template named Test.html in the main folder, then I call in the MainController.class.php between the time with $this->display ()//$this->show () can be), Similarly, if it is IndexController.class.php, then a folder named index will be built under the View folder.

if I want to access a method under the controller MainController.class.php Tess and this method does not exist, then this situation will occur, so that our use of the framework and version and so will be leaked, this is very unfriendly

At this point we will find a way to hide these, in the MainController.class.php to do a method named _empty

funtion _empty () {       echo// can also insert a view here }

If we are accessing a controller that does not exist, we will also disclose our information so that we need to build a controller named Emptycontroller in the folder controller

<? phpnamespace Home/Controller;  Use think/Controller; class extends controller{      function// If the customer is accessing an empty controller, then the inside method must also be empty               {                    echo"Sir, this controller does not exist";              }}

thinkphp Frame Empty Controller

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.