【发布时间】:2017-09-14 05:59:07
【问题描述】:
我有一个问题想问大家,我想在 codeigniter 中全局实现以下功能:
$ci =& get_instance();
我有一个致命错误:
Fatal error: Uncaught Error: Using $this when not in object context:
我想将 $ci 用于 $this,但我如何在全局范围内提及 $ci =& get_instance()?
我必须把 $ci =& get_instance();每个函数和每个文件中的代码。 请帮忙。
这是我的测试代码:
public static function index()
{
$ci =& get_instance();
$redirect = $ci->auth->is_logged_in(false, false);
}
【问题讨论】:
-
向我们展示代码。这不是必需的
$ci =& get_instance();总是 -
现在请检查我的代码@AbdullaNilam
-
加
$this>auth->is_logged_in就够了 -
好吧,让我试试@AbdullaNilam
-
添加
$this而不是$ci
标签: php codeigniter-3