ThinkPHP5.0 Framework controller inheritance base and custom class case study

Source: Internet
Author: User
This time, we bring you ThinkPHP5.0. Framework controller inheritance base and custom class case study, ThinkPHP5.0 framework controller successor base and custom class of attention to what, the following is the actual case, take a look. Z

Inherit the system controller base class:

<?phpnamespace app\index\controller;use Think\controller;class Index extends controller{public  function Hello ()  {    return ' Hello,world ';  }}

Or customize a base controller class base:

<?phpnamespace app\index\controller;use think\controller;class Base extends controller{}

You can define some public methods in the base controller class (If you are not familiar with the basic knowledge of the class, refer to the PHP classes and Objects section is very clear, do not do in-depth).

Then all of the following controller classes are applied to inherit base:

<?phpnamespace app\index\controller;use App\index\controller\base;class Index extends base{public  function Hello ()  {    return ' Hello,world ';  }}

It is recommended to uniformly define your own controller base class for the application, which is convenient for later extension.

Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!

Recommended reading:

How to implement ADODB transaction processing in PHP

How to use thinkphp5+uploadify for file uploads

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.