【发布时间】:2014-03-17 09:00:01
【问题描述】:
我在这里四处寻找可以帮助我了解全球化变量和 CI 实例所需的帖子。我发现了这篇很棒的帖子。
get_instance() in Codeigniter: Why assign it to a variable?
问题在于,当我在自己的应用程序中尝试它时,我收到了以下错误。
Fatal error: Call to undefined function CI() in .../application/core/MY_Controller.php on line 6
我不确定这是为什么。谁能详细说明一下?
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class MY_Controller extends CI_Controller {
public $module;
public function __construct() {
parent::__construct();
CI()->module = $this->module = $this->router->fetch_module();
}
function CI()
{
static $CI;
isset($CI) || $CI = CI_Controller::get_instance();
return $CI;
}
}
【问题讨论】:
标签: php codeigniter