Home > PHP Framework > ThinkPHP > body text

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

藏色散人
Release: 2021-04-15 08:57:15
forward
1699 people have browsed it

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
{
Copy after 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
Copy after login
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!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template