0

如果我在文件下面扩展或者只是在 autoload.php 中自动加载它,我得到的只是 http 500,有时是空输出。MYControllerInterface.php 位于 application/libraries 下。

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

我已经在 MYcontrollerInterface 中注释掉了从 { 到 } 的所有内容...

我试过去掉结尾?>

我已经检查了在 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 */
?>

应用程序/日志/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
4

2 回答 2

1

如果你要扩展一个控制器(它是一个核心类),它需要进入 /application/core.

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

更新扩展控制器必须称为 MY_Controller (根据加载程序类)。

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

class foo extends MY_Controller {
    function __construct() {
        parent::construct();
    }
}
于 2012-04-12T11:43:08.310 回答
-1

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

于 2012-04-12T11:38:26.880 回答