Isn’t there a public common class in thinkphp5? Moreover, there is also a common class definition under the default APP. If there is no common under the module, it will be inherited under the APP. After the common.php file is created under the controller module, it can be inherited directly without reference. . . It’s also easy to control and reduces code. . . Creating a new Base is a bit unnecessary, isn't it? Please ask the teacher to clarify! !
ringa_lee2017-09-11 17:15:12
It is definitely necessary. Many public operations must be written in the base.php file. For example, if you log in, you can just make a judgment in the base.php file. You don’t need to verify it in the controllers of other subclasses. Whether you are logged in or not, you need to write the login verification in the public common class, and you need to verify it once in each controller. It is no different from process-oriented development, and you cannot experience the meaning of object-oriented development.