简体   繁体   中英

CodeIgniter Controller displays blank page when calling parent constructor

<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Home extends MY_Controller {
      public function __construct(){
          parent::__construct();
      }
}

The code stops executing after calling the parent constructor, without giving absolutely any error messages. If I echo something before constructor call, it is echoed.If i remove the database from auto load library it will display error message .I have configured correct database details on the database file.Any one please help me?

The Question has very few information, anyway I will post this answer so that you can debug your program. If you can give more information I can edit the answer as well.

It sounds like you may have a problem in the MY_Controller , to make sure that replace you Home Controller with the following code.

<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {

      public function index(){
         echo "hey I am working";
     }
}

If this works, we can come to the conclusion that your MY_Controller has an error. In that case we need to see the MY_Controller to help further.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM