Home  >  Article  >  PHP Framework  >  What happens when the TP5 framework namespace controller inheritance is invalid?

What happens when the TP5 framework namespace controller inheritance is invalid?

藏色散人
藏色散人forward
2021-04-14 09:52:281614browse

The following tutorial column of thinkphp will introduce to you what happens when the TP5 framework namespace controller inheritance is invalid. I hope it will be helpful to friends in need!

Today I would like to share with you the TP5 namespace

There are always problems with TP5 when I am working on projects these days. The company needs to write a small function login function

Then it is invalid when inheriting the login, so I will sort it out for everyone. The masters will skip it. This is still relatively basic. If it is useful, everyone will take a look. If it is not useful, everyone will skip it.

namespace app\index\Controller;
use think\Controller;
use think\Request;
use think\Db;
use app\index\controller\Login;
class Formall extends Login
{
1. namespace app\index\Controller; This means the class named Formall in app –> index–> controller –>

2. This class The first letter of the name must be capitalized. Formal The first letter of the inherited class must also be capitalized. Login


The following is the inherited class

namespace app\index\Controller;
use think\Controller;
use think\Request;
use think\Db;
class Login extends Controller
1. The namespace is also app \index\Controller; This is the Login class below

2. The class must also be capitalized Login

3. This class must inherit Controller
4. Not only must it inherit Controller, but also use think\Controller;

namespace app\index\Controller; This controller represents the directory

use think\Controller; This Controller represents the Controller class in the think system class, these two Controllers

These two are They have completely different meanings. Please note that if the capitalization of any word in

is wrong, an error will be reported.

Related recommendations:
The latest 10 thinkphp video tutorials

The above is the detailed content of What happens when the TP5 framework namespace controller inheritance is invalid?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete