CodeIgniter扩展文件导致http 500

时间:2012-04-12 11:30:33

标签: php apache codeigniter

如果我在文件 OR 下面扩展,只需在autoload.php中自动加载它,我得到的是http 500,有时是空输出。 MYControllerInterface.php位于应用程序/库下。

我已经将整个目录(递归)chmod到0777.我已经在根目录中创建了一个带有RewriteEngine On和Off的.htaccess。

我在MYcontrollerInterface中评论了{to}的所有内容...

我已尝试删除结尾?>

我已经检查过在php配置中启用了mod_rewrite ...这太神秘了!

<?php 
class MYcontrollerInterface extends CI_Controller {
    public function __construct() {
        parent::__construct();
        //$this->load->helper('url');
    }   

    function build_page($main_content_view, $data) {
        /*
        $this->load->view('header', $data);    
        //$this->load->view('content', $data);      
        //$this->load->view($main_content_view, $data, true);
        $this->load->view('footer', $data);   
        */      
        echo 'apa';
    }   
}

/* End of file MycontrollerInterface.php */
/* Location: ./application/controllers/MYcontrollerInterface.php */
?>

application / logs / log-2012-04-12.php:

DEBUG - 2012-04-12 13:21:22 --> Config Class Initialized
DEBUG - 2012-04-12 13:21:22 --> Hooks Class Initialized
DEBUG - 2012-04-12 13:21:22 --> Utf8 Class Initialized
DEBUG - 2012-04-12 13:21:22 --> UTF-8 Support Enabled
DEBUG - 2012-04-12 13:21:22 --> URI Class Initialized
DEBUG - 2012-04-12 13:21:22 --> Router Class Initialized
DEBUG - 2012-04-12 13:21:22 --> Output Class Initialized
DEBUG - 2012-04-12 13:21:22 --> Security Class Initialized
DEBUG - 2012-04-12 13:21:22 --> Input Class Initialized
下面的

一直在重复:

DEBUG - 2012-04-12 13:21:22 --> Global POST and COOKIE data sanitized
DEBUG - 2012-04-12 13:21:22 --> Language Class Initialized
DEBUG - 2012-04-12 13:21:22 --> Loader Class Initialized
DEBUG - 2012-04-12 13:21:22 --> Controller Class Initialized
DEBUG - 2012-04-12 13:21:22 --> Final output sent to browser
DEBUG - 2012-04-12 13:21:22 --> Total execution time: 0.0320
DEBUG - 2012-04-12 13:21:38 --> Config Class Initialized
DEBUG - 2012-04-12 13:21:38 --> Hooks Class Initialized
DEBUG - 2012-04-12 13:21:38 --> Utf8 Class Initialized
DEBUG - 2012-04-12 13:21:38 --> UTF-8 Support Enabled
DEBUG - 2012-04-12 13:21:38 --> URI Class Initialized
DEBUG - 2012-04-12 13:21:38 --> Router Class Initialized
DEBUG - 2012-04-12 13:21:38 --> Output Class Initialized
DEBUG - 2012-04-12 13:21:38 --> Security Class Initialized
DEBUG - 2012-04-12 13:21:38 --> Input Class Initialized

2 个答案:

答案 0 :(得分:1)

如果要扩展控制器(这是一个核心类),则需要进入/ application / core。

同时检查你的前缀,CI2标准是MY_(在第109行检查你的$ config ['subclass_prefix']。

UPDATE 必须将扩展控制器调用为MY_Controller(根据加载器类)。

然后你会像......一样使用它。

class foo extends MY_Controller {
    function __construct() {
        parent::construct();
    }
}

答案 1 :(得分:-1)

您可以将此文件放在system/libraries文件夹中,然后尝试扩展它。