CI Version 3.1.3 My Controller Call to undefined method - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: CI Version 3.1.3 My Controller Call to undefined method (/showthread.php?tid=67265) |
CI Version 3.1.3 My Controller Call to undefined method - tahirsanaullah - 02-02-2017 Hi, I am using CI Version 3.1.3 I have a created controller on application/core MY_Controller.php <?php class MY_Controller extends CI_Controller { public function __construct() { parent::__construct(); } public function test() { echo 'test'; } } and try to call on application\controllers Dashboard.php code is <?php class dashboard extends CI_Controller { function __construct() { parent:: __construct(); $this->load->model('admin_database'); $this->load->helper('url'); $this->load->library('session'); } public function index() { $this->test(); } } but its giving error A PHP Error was encountered Severity: Error Message: Call to undefined method dashboard::test() Filename: controllers/Dashboard.php Line Number: 22 Backtrace: please some one help me, will thank full thanks RE: CI Version 3.1.3 My Controller Call to undefined method - Narf - 02-02-2017 You're defining the method in MY_Controller and then extending CI_Controller ... RE: CI Version 3.1.3 My Controller Call to undefined method - tahirsanaullah - 02-02-2017 thanks for reply please read the code, actually I need a core controller which may i use in whole application thanks RE: CI Version 3.1.3 My Controller Call to undefined method - Wouter60 - 02-02-2017 Please read Narf's answer. If your dashboard controller needs to call methods in your "MY_Controller", you should not use CI_Controller but MY_Controller in the definition of the dashboard class: PHP Code: class dashboard extends MY_Controller { RE: CI Version 3.1.3 My Controller Call to undefined method - tahirsanaullah - 02-02-2017 hi, thanks a lot it works |