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 ";}}