codeigniter: extending common controller

后端 未结 3 2062
长情又很酷
长情又很酷 2021-01-24 21:31

I\'ve read all the post I found regarding this issue but nothing works. I\'m using Codeigniter 2.02 in a LAMP with Apache2.2 and PHP5.3.2

I\'m trying to create a common

3条回答
  •  独厮守ぢ
    2021-01-24 21:36

    This bit is correct

    public function __contstruct() instead of public function Parent_controller()

    But what you're looking for is the MY_ prefix. So if you create the controller in the /application/libraries/ folder and call the file MY_Controller.php and the class MY_Controller it'll work.

    You can also change the MY_ prefix to whatever you'd like in the config.php file. Look for:

    /*
    |--------------------------------------------------------------------------
    | Class Extension Prefix
    |--------------------------------------------------------------------------
    |
    | This item allows you to set the filename/classname prefix when extending
    | native libraries.  For more information please see the user guide:
    |
    | http://codeigniter.com/user_guide/general/core_classes.html
    | http://codeigniter.com/user_guide/general/creating_libraries.html
    |
    */
    $config['subclass_prefix'] = 'MY_';
    

    For further reading and a more depth explanation see http://codeigniter.com/user_guide/general/core_classes.html

提交回复
热议问题