我很难在CodeIgniter中启用探查器。我已将其添加到$libraries
配置数组中,因此应自动加载。但是我收到了错误......
Fatal error: Call to a member function enable_profiler() on a non-object in C:\......\application\core\publiccontroller.php on line 6
我的代码是:
<?php
class PublicController extends CI_Controller {
public function __construct () {
// enable profiler for development
if (ENVIRONMENT == 'development') {
$this->output->enable_profiler(true);
}
}
}
?>
autoload.php
有......
/*
| -------------------------------------------------------------------
| Auto-load Libraries
| -------------------------------------------------------------------
| These are the classes located in the system/libraries folder
| or in your application/libraries folder.
|
| Prototype:
|
| $autoload['libraries'] = array('database', 'session', 'xmlrpc');
*/
$autoload['libraries'] = array('profiler');
我做错了什么?我正在使用CI版本2
答案 0 :(得分:2)
请注意:此建议解决了CI 1.x中的类似问题,未在CI 2中进行测试。
问题,我怀疑是你在对象完全启动之前在构造函数中调用它。你能确认$ this-&gt;加载存在吗?如果将parent::__construct();
作为构造函数的第一行会发生什么?