Null controller of ThinkPHP framework and thinkphp framework Controller

Source: Internet
Author: User

Null controller of ThinkPHP framework and thinkphp framework Controller

HOME indicates that the module frontend can use the Admin Model View Controller in the Home background, collectively referred to as MVC.

Model is a data Model. The View that deals with databases represents the displayed Model Controller.

The MVC pattern follows the rule that is better than the configuration.

In the Conf folder in the Home folder. add return array ('show _ PAGE_TRACE '=> TRUE // enable trace information) to the php configuration file so that we can debug or view errors.

The common folder in ThinkPHP is the convertion under the conf folder of some functions provided by the TP framework. php contains all TP configurations. do not modify the Lang Language Pack Library. The Library stores core class files. The think folder contains many class files containing controller. class. php is the parent class of all controllers. 

Now I have created a MainController In the config file of the conf folder in the Home folder. class. in the PHP file, there is a test method, and this test is intended to display a template, so I will create a folder under the view folder that corresponds to MainController. This folder should be named main,( I created a template named test.html under the mainfolder, then I am in MainController. class. use $ this-> display () // $ this-> show () between calls in php. Similarly, use IndexController. class. in php, create a folder named Index under the view folder.

If you want to access the Controller MainController. class. the tess method in php does not exist, so this situation will occur, so that the framework and version we use will be leaked, which is very unfriendly.

 

In this case, we need to find a way to hide this and create a method named _ empty in MainController. class. php.

 

Funtion _ empty () {echo ", your access method is incorrect"; // You can also insert a view here}

 

If we access a non-existent Controller, it will also leak our information. In this case, we need to create a Controller named EmptyController in the Controller folder.

<? Phpnamespace Home/Controller; use Think/Controller; class EmptyController extends Controller {function _ empty () // if the customer accesses an empty Controller, then the method in it must be empty {echo "guest, this controller does not exist ";}}

 

 

 

 

 

 

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.