CI3 How to use controller inheritance

Source: Internet
Author: User

These two days to see the next CI3, want to use controller inheritance, later found CI inheritance is another mystery, here to make a note.

1. Check the application\config\config.php file

$config [' subclass_prefix '] = ' my_ ';

Value is My_, then your controller needs to start with this.

2. Create a new my_controller.php file under the Application\core folder

<?phpdefined (' BasePath ') or exit (' No Direct script access allowed ');/***my_controller**/class My_controller extends Ci_controller{public function __construct () {parent::__construct ();}}? >

3. Use it in your controllers

<?phpdefined (' BasePath ') or exit (' No Direct script access allowed '); class User extends my_controller{public functio    n __construct () {parent::__construct (); $this->load->library (' theme '); }}?>


CI3 How to use controller inheritance

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.