Php 扩展控制器代码点火器
我已经在IIS上安装了Codeigniter。一切都很顺利 我正在尝试扩展CI_控制器类。我这样做的原因是在构造函数中进行安全检查。某些控制器将扩展CI_控制器。一些需要安全的控制器将扩展MY_控制器。这对我来说似乎是个好办法 到目前为止,我遵循了以下说明: 但是当我调用扩展我的_控制器的页面时,我得到一个空白页面。 检查Firebug中的网络选项卡,我看到“500内部服务器错误” 我检查了我的CI日志,我看到:Php 扩展控制器代码点火器,php,codeigniter,Php,Codeigniter,我已经在IIS上安装了Codeigniter。一切都很顺利 我正在尝试扩展CI_控制器类。我这样做的原因是在构造函数中进行安全检查。某些控制器将扩展CI_控制器。一些需要安全的控制器将扩展MY_控制器。这对我来说似乎是个好办法 到目前为止,我遵循了以下说明: 但是当我调用扩展我的_控制器的页面时,我得到一个空白页面。 检查Firebug中的网络选项卡,我看到“500内部服务器错误” 我检查了我的CI日志,我看到: DEBUG - 2014-11-24 10:26:47 --> Confi
DEBUG - 2014-11-24 10:26:47 --> Config Class Initialized
DEBUG - 2014-11-24 10:26:47 --> Hooks Class Initialized
DEBUG - 2014-11-24 10:26:47 --> Utf8 Class Initialized
DEBUG - 2014-11-24 10:26:47 --> UTF-8 Support Enabled
DEBUG - 2014-11-24 10:26:47 --> URI Class Initialized
DEBUG - 2014-11-24 10:26:47 --> Router Class Initialized
DEBUG - 2014-11-24 10:26:47 --> Output Class Initialized
DEBUG - 2014-11-24 10:26:47 --> Security Class Initialized
DEBUG - 2014-11-24 10:26:47 --> Input Class Initialized
DEBUG - 2014-11-24 10:26:47 --> Global POST and COOKIE data sanitized
DEBUG - 2014-11-24 10:26:47 --> Language Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Config Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Hooks Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Utf8 Class Initialized
DEBUG - 2014-11-24 11:00:14 --> UTF-8 Support Enabled
DEBUG - 2014-11-24 11:00:14 --> URI Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Router Class Initialized
DEBUG - 2014-11-24 11:00:14 --> No URI present. Default controller set.
DEBUG - 2014-11-24 11:00:14 --> Output Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Security Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Input Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Global POST and COOKIE data sanitized
DEBUG - 2014-11-24 11:00:14 --> Language Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Loader Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Helper loaded: url_helper
DEBUG - 2014-11-24 11:00:14 --> Session Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Helper loaded: string_helper
DEBUG - 2014-11-24 11:00:14 --> Session routines successfully run
DEBUG - 2014-11-24 11:00:14 --> Controller Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Database Driver Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Model Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Model Class Initialized
DEBUG - 2014-11-24 11:00:14 --> File loaded: application/views/user/session_box.php
DEBUG - 2014-11-24 11:00:14 --> File loaded: application/views/public/public_menu.php
DEBUG - 2014-11-24 11:00:14 --> File loaded: application/views/public/welcome_message.php
DEBUG - 2014-11-24 11:00:14 --> File loaded: application/views/template.php
DEBUG - 2014-11-24 11:00:14 --> Final output sent to browser
DEBUG - 2014-11-24 11:00:14 --> Total execution time: 0.2295
现在,对于正常参考点,当我加载任何不扩展我的_控制器的控制器时,我看到:
DEBUG - 2014-11-24 10:26:47 --> Config Class Initialized
DEBUG - 2014-11-24 10:26:47 --> Hooks Class Initialized
DEBUG - 2014-11-24 10:26:47 --> Utf8 Class Initialized
DEBUG - 2014-11-24 10:26:47 --> UTF-8 Support Enabled
DEBUG - 2014-11-24 10:26:47 --> URI Class Initialized
DEBUG - 2014-11-24 10:26:47 --> Router Class Initialized
DEBUG - 2014-11-24 10:26:47 --> Output Class Initialized
DEBUG - 2014-11-24 10:26:47 --> Security Class Initialized
DEBUG - 2014-11-24 10:26:47 --> Input Class Initialized
DEBUG - 2014-11-24 10:26:47 --> Global POST and COOKIE data sanitized
DEBUG - 2014-11-24 10:26:47 --> Language Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Config Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Hooks Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Utf8 Class Initialized
DEBUG - 2014-11-24 11:00:14 --> UTF-8 Support Enabled
DEBUG - 2014-11-24 11:00:14 --> URI Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Router Class Initialized
DEBUG - 2014-11-24 11:00:14 --> No URI present. Default controller set.
DEBUG - 2014-11-24 11:00:14 --> Output Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Security Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Input Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Global POST and COOKIE data sanitized
DEBUG - 2014-11-24 11:00:14 --> Language Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Loader Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Helper loaded: url_helper
DEBUG - 2014-11-24 11:00:14 --> Session Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Helper loaded: string_helper
DEBUG - 2014-11-24 11:00:14 --> Session routines successfully run
DEBUG - 2014-11-24 11:00:14 --> Controller Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Database Driver Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Model Class Initialized
DEBUG - 2014-11-24 11:00:14 --> Model Class Initialized
DEBUG - 2014-11-24 11:00:14 --> File loaded: application/views/user/session_box.php
DEBUG - 2014-11-24 11:00:14 --> File loaded: application/views/public/public_menu.php
DEBUG - 2014-11-24 11:00:14 --> File loaded: application/views/public/welcome_message.php
DEBUG - 2014-11-24 11:00:14 --> File loaded: application/views/template.php
DEBUG - 2014-11-24 11:00:14 --> Final output sent to browser
DEBUG - 2014-11-24 11:00:14 --> Total execution time: 0.2295
谁能告诉我怎么了
我的控制器
class MY_Controller extends CI_Controller{
private static $instance;
/**
* Constructor
*/
function __construct()
{
parent::__construct();
}
public static function &get_instance()
{
return self::$instance;
}
}
扩展它的控制器:
class Project extends MY_Controller{
public function __construct()
{
parent::__construct();
$this->load->database();
$this->load->model('user_model');
}
public function index()
{
var_dump("hi");
}
}
将MY_控制器更改为:
<?php
class MY_Controller extends CI_Controller
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
}
}
首先,在扩展控制器之前,一切都正常吗?第二,你能展示你的MY_Controller
类的代码和扩展它的控制器吗。。。不是全部,只是顶部。最后,文件名是否与类名完全匹配(区分大小写)?好的,Ross,我添加了代码以回答您的问题:每个不扩展我的\u控制器的控制器都工作得很好。MY_Controller.php文件名与“MY_Controller”的控制器名完全匹配(包括大小写)。@GRY,为了排除一个问题,您有$config['subclass_prefix']='MY_';在application/config/config.php(?)@eduardata Yes先生中定义。我已经在config中将子类前缀定义为“MY_u3;”,我刚刚测试了代码,它不会在private static$instance中抛出错误代码>或方法…但仍然不需要:)